Search in sources :

Example 21 with Planet

use of micdoodle8.mods.galacticraft.api.galaxies.Planet in project Galacticraft by micdoodle8.

the class EntityTieredRocket method onReachAtmosphere.

@Override
public void onReachAtmosphere() {
    // Launch controlled
    if (this.destinationFrequency != -1) {
        if (this.worldObj.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.worldObj.provider.getDimensionId()) {
                WorldProvider targetDim = WorldUtil.getProviderForDimensionServer(this.targetDimension);
                if (targetDim != null && targetDim.worldObj 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.riddenByEntity != null) {
                            WorldUtil.transferEntityToDimension(this.riddenByEntity, this.targetDimension, (WorldServer) targetDim.worldObj, false, this);
                        } else {
                            Entity e = WorldUtil.transferEntityToDimension(this, this.targetDimension, (WorldServer) targetDim.worldObj, 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;
                if (this.riddenByEntity != null) {
                    WorldUtil.forceMoveEntityToPos(this.riddenByEntity, (WorldServer) this.worldObj, 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.worldObj.provider instanceof IExitHeight ? ((IExitHeight) this.worldObj.provider).getYCoordinateToTeleport() : 1200) - 200);
            return;
        }
    }
    // Not launch controlled
    if (!this.worldObj.isRemote) {
        if (this.riddenByEntity instanceof EntityPlayerMP) {
            EntityPlayerMP player = (EntityPlayerMP) this.riddenByEntity;
            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) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IExitHeight(micdoodle8.mods.galacticraft.api.world.IExitHeight)

Example 22 with Planet

use of micdoodle8.mods.galacticraft.api.galaxies.Planet in project Galacticraft by micdoodle8.

the class GCPlayerHandler method checkThermalStatus.

protected void checkThermalStatus(EntityPlayerMP player, GCPlayerStats playerStats) {
    if (player.worldObj.provider instanceof IGalacticraftWorldProvider && !player.capabilities.isCreativeMode && !CompatibilityManager.isAndroid(player)) {
        final ItemStack thermalPaddingHelm = playerStats.getExtendedInventory().getStackInSlot(6);
        final ItemStack thermalPaddingChestplate = playerStats.getExtendedInventory().getStackInSlot(7);
        final ItemStack thermalPaddingLeggings = playerStats.getExtendedInventory().getStackInSlot(8);
        final ItemStack thermalPaddingBoots = playerStats.getExtendedInventory().getStackInSlot(9);
        float lowestThermalStrength = 0.0F;
        if (thermalPaddingHelm != null && thermalPaddingChestplate != null && thermalPaddingLeggings != null && thermalPaddingBoots != null) {
            if (thermalPaddingHelm.getItem() instanceof IItemThermal) {
                lowestThermalStrength += ((IItemThermal) thermalPaddingHelm.getItem()).getThermalStrength();
            }
            if (thermalPaddingChestplate.getItem() instanceof IItemThermal) {
                lowestThermalStrength += ((IItemThermal) thermalPaddingChestplate.getItem()).getThermalStrength();
            }
            if (thermalPaddingLeggings.getItem() instanceof IItemThermal) {
                lowestThermalStrength += ((IItemThermal) thermalPaddingLeggings.getItem()).getThermalStrength();
            }
            if (thermalPaddingBoots.getItem() instanceof IItemThermal) {
                lowestThermalStrength += ((IItemThermal) thermalPaddingBoots.getItem()).getThermalStrength();
            }
            lowestThermalStrength /= 4.0F;
            // It shouldn't be negative, but just in case!
            lowestThermalStrength = Math.abs(lowestThermalStrength);
        }
        IGalacticraftWorldProvider provider = (IGalacticraftWorldProvider) player.worldObj.provider;
        float thermalLevelMod = provider.getThermalLevelModifier();
        float absThermalLevelMod = Math.abs(thermalLevelMod);
        if (absThermalLevelMod > 0D) {
            int thermalLevelCooldownBase = Math.abs(MathHelper.floor_float(200 / thermalLevelMod));
            int normaliseCooldown = MathHelper.floor_float(150 / lowestThermalStrength);
            int thermalLevelTickCooldown = thermalLevelCooldownBase;
            if (thermalLevelTickCooldown < 1) {
                // Prevent divide by zero errors
                thermalLevelTickCooldown = 1;
            }
            if (thermalPaddingHelm != null && thermalPaddingChestplate != null && thermalPaddingLeggings != null && thermalPaddingBoots != null) {
                // If the thermal strength exceeds the dimension's thermal level mod, it can't improve the normalise
                // This factor of 1.5F is chosen so that a combination of Tier 1 and Tier 2 thermal isn't enough to normalise on Venus (three Tier 2, one Tier 1 stays roughly constant)
                float relativeFactor = Math.max(1.0F, absThermalLevelMod / lowestThermalStrength) / 1.5F;
                normaliseCooldown = MathHelper.floor_float(normaliseCooldown / absThermalLevelMod * relativeFactor);
                if (normaliseCooldown < 1) {
                    // Prevent divide by zero errors
                    normaliseCooldown = 1;
                }
                // Player is wearing all required thermal padding items
                if ((player.ticksExisted - 1) % normaliseCooldown == 0) {
                    this.normaliseThermalLevel(player, playerStats, 1);
                }
                thermalLevelMod /= Math.max(1.0F, lowestThermalStrength / 2.0F);
                absThermalLevelMod = Math.abs(thermalLevelMod);
            }
            if (OxygenUtil.isAABBInBreathableAirBlock(player, true)) {
                playerStats.setThermalLevelNormalising(true);
                this.normaliseThermalLevel(player, playerStats, 1);
                // If player is in ambient thermal area, slowly reset to normal
                return;
            }
            // For each piece of thermal equipment being used, slow down the the harmful thermal change slightly
            if (thermalPaddingHelm != null) {
                thermalLevelTickCooldown += thermalLevelCooldownBase;
            }
            if (thermalPaddingChestplate != null) {
                thermalLevelTickCooldown += thermalLevelCooldownBase;
            }
            if (thermalPaddingLeggings != null) {
                thermalLevelTickCooldown += thermalLevelCooldownBase;
            }
            if (thermalPaddingBoots != null) {
                thermalLevelTickCooldown += thermalLevelCooldownBase;
            }
            // Instead of increasing/decreasing the thermal level by a large amount every ~200 ticks, increase/decrease
            // by a small amount each time (still the same average increase/decrease)
            int thermalLevelTickCooldownSingle = MathHelper.floor_double(thermalLevelTickCooldown / absThermalLevelMod);
            if (thermalLevelTickCooldownSingle < 1) {
                // Prevent divide by zero errors
                thermalLevelTickCooldownSingle = 1;
            }
            if ((player.ticksExisted - 1) % thermalLevelTickCooldownSingle == 0) {
                int last = playerStats.getThermalLevel();
                playerStats.setThermalLevel((int) Math.min(Math.max(playerStats.getThermalLevel() + (thermalLevelMod < 0 ? -1 : 1), -22), 22));
                if (playerStats.getThermalLevel() != last) {
                    this.sendThermalLevelPacket(player, playerStats);
                }
            }
            // If the normalisation is outpacing the freeze/overheat
            playerStats.setThermalLevelNormalising(thermalLevelTickCooldownSingle > normaliseCooldown && thermalPaddingHelm != null && thermalPaddingChestplate != null && thermalPaddingLeggings != null && thermalPaddingBoots != null);
            if (!playerStats.isThermalLevelNormalising()) {
                if ((player.ticksExisted - 1) % thermalLevelTickCooldown == 0) {
                    if (Math.abs(playerStats.getThermalLevel()) >= 22) {
                        player.attackEntityFrom(DamageSourceGC.thermal, 1.5F);
                    }
                }
                if (playerStats.getThermalLevel() < -15) {
                    player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, 2, true, true));
                }
                if (playerStats.getThermalLevel() > 15) {
                    player.addPotionEffect(new PotionEffect(Potion.confusion.id, 5, 2, true, true));
                }
            }
        } else // Normalise thermal level if on Space Station or non-modifier planet
        {
            playerStats.setThermalLevelNormalising(true);
            this.normaliseThermalLevel(player, playerStats, 2);
        }
    } else // Normalise thermal level if on Overworld or any non-GC dimension
    {
        playerStats.setThermalLevelNormalising(true);
        this.normaliseThermalLevel(player, playerStats, 3);
    }
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) IItemThermal(micdoodle8.mods.galacticraft.api.item.IItemThermal) PotionEffect(net.minecraft.potion.PotionEffect) ItemStack(net.minecraft.item.ItemStack) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint)

Example 23 with Planet

use of micdoodle8.mods.galacticraft.api.galaxies.Planet in project Galacticraft by micdoodle8.

the class AsteroidsModule method init.

@Override
public void init(FMLInitializationEvent event) {
    // Set creative tab item to Astro Miner
    ((CreativeTabGC) GalacticraftCore.galacticraftItemsTab).setItemForTab(AsteroidsItems.astroMiner);
    this.registerMicroBlocks();
    SchematicRegistry.registerSchematicRecipe(new SchematicTier3Rocket());
    SchematicRegistry.registerSchematicRecipe(new SchematicAstroMiner());
    GalacticraftCore.packetPipeline.addDiscriminator(7, PacketSimpleAsteroids.class);
    AsteroidsTickHandlerServer eventHandler = new AsteroidsTickHandlerServer();
    MinecraftForge.EVENT_BUS.register(eventHandler);
    this.registerEntities();
    RecipeManagerAsteroids.loadRecipes();
    AsteroidsModule.planetAsteroids = new Planet("asteroids").setParentSolarSystem(GalacticraftCore.solarSystemSol);
    AsteroidsModule.planetAsteroids.setDimensionInfo(ConfigManagerAsteroids.dimensionIDAsteroids, WorldProviderAsteroids.class).setTierRequired(3);
    AsteroidsModule.planetAsteroids.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(1.375F, 1.375F)).setRelativeOrbitTime(45.0F).setPhaseShift((float) (Math.random() * (2 * Math.PI)));
    AsteroidsModule.planetAsteroids.setBodyIcon(new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/celestialbodies/asteroid.png"));
    AsteroidsModule.planetAsteroids.setAtmosphere(new AtmosphereInfo(false, false, false, -1.5F, 0.05F, 0.0F));
    AsteroidsModule.planetAsteroids.addChecklistKeys("equip_oxygen_suit", "craft_grapple_hook", "thermal_padding");
    GalaxyRegistry.registerPlanet(AsteroidsModule.planetAsteroids);
    GalacticraftRegistry.registerTeleportType(WorldProviderAsteroids.class, new TeleportTypeAsteroids());
    HashMap<Integer, ItemStack> input = new HashMap<>();
    ItemStack plateTier3 = new ItemStack(AsteroidsItems.basicItem, 1, 5);
    ItemStack rocketFinsTier2 = new ItemStack(AsteroidsItems.basicItem, 1, 2);
    input.put(1, new ItemStack(AsteroidsItems.heavyNoseCone));
    input.put(2, plateTier3);
    input.put(3, plateTier3);
    input.put(4, plateTier3);
    input.put(5, plateTier3);
    input.put(6, plateTier3);
    input.put(7, plateTier3);
    input.put(8, plateTier3);
    input.put(9, plateTier3);
    input.put(10, plateTier3);
    input.put(11, plateTier3);
    input.put(12, new ItemStack(GCItems.rocketEngine, 1, 1));
    input.put(13, rocketFinsTier2);
    input.put(14, rocketFinsTier2);
    input.put(15, new ItemStack(AsteroidsItems.basicItem, 1, 1));
    input.put(16, new ItemStack(GCItems.rocketEngine, 1, 1));
    input.put(17, rocketFinsTier2);
    input.put(18, rocketFinsTier2);
    input.put(19, null);
    input.put(20, null);
    input.put(21, null);
    GalacticraftRegistry.addT3RocketRecipe(new NasaWorkbenchRecipe(new ItemStack(AsteroidsItems.tier3Rocket, 1, 0), input));
    HashMap<Integer, ItemStack> input2 = new HashMap<Integer, ItemStack>(input);
    input2.put(19, new ItemStack(Blocks.chest));
    input2.put(20, null);
    input2.put(21, null);
    GalacticraftRegistry.addT3RocketRecipe(new NasaWorkbenchRecipe(new ItemStack(AsteroidsItems.tier3Rocket, 1, 1), input2));
    input2 = new HashMap<Integer, ItemStack>(input);
    input2.put(19, null);
    input2.put(20, new ItemStack(Blocks.chest));
    input2.put(21, null);
    GalacticraftRegistry.addT3RocketRecipe(new NasaWorkbenchRecipe(new ItemStack(AsteroidsItems.tier3Rocket, 1, 1), input2));
    input2 = new HashMap<Integer, ItemStack>(input);
    input2.put(19, null);
    input2.put(20, null);
    input2.put(21, new ItemStack(Blocks.chest));
    GalacticraftRegistry.addT3RocketRecipe(new NasaWorkbenchRecipe(new ItemStack(AsteroidsItems.tier3Rocket, 1, 1), input2));
    input2 = new HashMap<Integer, ItemStack>(input);
    input2.put(19, new ItemStack(Blocks.chest));
    input2.put(20, new ItemStack(Blocks.chest));
    input2.put(21, null);
    GalacticraftRegistry.addT3RocketRecipe(new NasaWorkbenchRecipe(new ItemStack(AsteroidsItems.tier3Rocket, 1, 2), input2));
    input2 = new HashMap<Integer, ItemStack>(input);
    input2.put(19, new ItemStack(Blocks.chest));
    input2.put(20, null);
    input2.put(21, new ItemStack(Blocks.chest));
    GalacticraftRegistry.addT3RocketRecipe(new NasaWorkbenchRecipe(new ItemStack(AsteroidsItems.tier3Rocket, 1, 2), input2));
    input2 = new HashMap<Integer, ItemStack>(input);
    input2.put(19, null);
    input2.put(20, new ItemStack(Blocks.chest));
    input2.put(21, new ItemStack(Blocks.chest));
    GalacticraftRegistry.addT3RocketRecipe(new NasaWorkbenchRecipe(new ItemStack(AsteroidsItems.tier3Rocket, 1, 2), input2));
    input2 = new HashMap<Integer, ItemStack>(input);
    input2.put(19, new ItemStack(Blocks.chest));
    input2.put(20, new ItemStack(Blocks.chest));
    input2.put(21, new ItemStack(Blocks.chest));
    GalacticraftRegistry.addT3RocketRecipe(new NasaWorkbenchRecipe(new ItemStack(AsteroidsItems.tier3Rocket, 1, 3), input2));
    input = new HashMap<Integer, ItemStack>();
    input.put(1, new ItemStack(GCItems.heavyPlatingTier1));
    input.put(3, new ItemStack(GCItems.heavyPlatingTier1));
    input.put(5, new ItemStack(GCItems.heavyPlatingTier1));
    input.put(11, new ItemStack(GCItems.heavyPlatingTier1));
    input.put(2, new ItemStack(AsteroidsItems.orionDrive));
    input.put(4, new ItemStack(AsteroidsItems.orionDrive));
    input.put(9, new ItemStack(AsteroidsItems.orionDrive));
    input.put(10, new ItemStack(AsteroidsItems.orionDrive));
    input.put(12, new ItemStack(AsteroidsItems.orionDrive));
    input.put(6, new ItemStack(GCItems.basicItem, 1, 14));
    input.put(7, new ItemStack(Blocks.chest));
    input.put(8, new ItemStack(Blocks.chest));
    input.put(13, new ItemStack(AsteroidsItems.basicItem, 1, 8));
    input.put(14, new ItemStack(GCItems.flagPole));
    GalacticraftRegistry.addAstroMinerRecipe(new NasaWorkbenchRecipe(new ItemStack(AsteroidsItems.astroMiner, 1, 0), input));
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_THERMAL_PADDING_T1_HELMET, EnumExtendedInventorySlot.THERMAL_HELMET, new ItemStack(AsteroidsItems.thermalPadding, 1, 0));
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_THERMAL_PADDING_T1_CHESTPLATE, EnumExtendedInventorySlot.THERMAL_CHESTPLATE, new ItemStack(AsteroidsItems.thermalPadding, 1, 1));
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_THERMAL_PADDING_T1_LEGGINGS, EnumExtendedInventorySlot.THERMAL_LEGGINGS, new ItemStack(AsteroidsItems.thermalPadding, 1, 2));
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_THERMAL_PADDING_T1_BOOTS, EnumExtendedInventorySlot.THERMAL_BOOTS, new ItemStack(AsteroidsItems.thermalPadding, 1, 3));
}
Also used : SchematicTier3Rocket(micdoodle8.mods.galacticraft.planets.asteroids.schematic.SchematicTier3Rocket) NasaWorkbenchRecipe(micdoodle8.mods.galacticraft.core.recipe.NasaWorkbenchRecipe) AtmosphereInfo(micdoodle8.mods.galacticraft.api.world.AtmosphereInfo) AsteroidsTickHandlerServer(micdoodle8.mods.galacticraft.planets.asteroids.tick.AsteroidsTickHandlerServer) HashMap(java.util.HashMap) SchematicAstroMiner(micdoodle8.mods.galacticraft.planets.asteroids.schematic.SchematicAstroMiner) WorldProviderAsteroids(micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids) ResourceLocation(net.minecraft.util.ResourceLocation) CelestialBody(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody) CreativeTabGC(micdoodle8.mods.galacticraft.core.util.CreativeTabGC) TeleportTypeAsteroids(micdoodle8.mods.galacticraft.planets.asteroids.dimension.TeleportTypeAsteroids) Planet(micdoodle8.mods.galacticraft.api.galaxies.Planet) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)7 ResourceLocation (net.minecraft.util.ResourceLocation)7 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)6 Planet (micdoodle8.mods.galacticraft.api.galaxies.Planet)4 AtmosphereInfo (micdoodle8.mods.galacticraft.api.world.AtmosphereInfo)4 Vector3f (org.lwjgl.util.vector.Vector3f)4 ScalableDistance (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody.ScalableDistance)3 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 CelestialBodyRenderEvent (micdoodle8.mods.galacticraft.api.event.client.CelestialBodyRenderEvent)2 SpaceStationRecipe (micdoodle8.mods.galacticraft.api.recipe.SpaceStationRecipe)2 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)2 Entity (net.minecraft.entity.Entity)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 PotionEffect (net.minecraft.potion.PotionEffect)2 WorldProvider (net.minecraft.world.WorldProvider)2 WorldServer (net.minecraft.world.WorldServer)2 SpawnListEntry (net.minecraft.world.biome.BiomeGenBase.SpawnListEntry)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2