Search in sources :

Example 46 with IGalacticraftWorldProvider

use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.

the class TickHandlerClientVenus method onClientTick.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
    final Minecraft minecraft = FMLClientHandler.instance().getClient();
    final WorldClient world = minecraft.world;
    if (world != null) {
        if (world.provider instanceof WorldProviderVenus) {
            if (world.provider.getSkyRenderer() == null) {
                world.provider.setSkyRenderer(new SkyProviderVenus((IGalacticraftWorldProvider) world.provider));
            }
            if (world.provider.getCloudRenderer() == null) {
                world.provider.setCloudRenderer(new CloudRenderer());
            }
            if (world.provider.getWeatherRenderer() == null) {
                world.provider.setWeatherRenderer(new WeatherRendererVenus());
            }
        }
    }
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) CloudRenderer(micdoodle8.mods.galacticraft.core.client.CloudRenderer) Minecraft(net.minecraft.client.Minecraft) WorldClient(net.minecraft.client.multiplayer.WorldClient) WorldProviderVenus(micdoodle8.mods.galacticraft.planets.venus.dimension.WorldProviderVenus) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 47 with IGalacticraftWorldProvider

use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.

the class RoomTreasureMars method addComponentParts.

@Override
public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox boundingBox) {
    for (int i = 0; i <= this.sizeX; i++) {
        for (int j = 0; j <= this.sizeY; j++) {
            for (int k = 0; k <= this.sizeZ; k++) {
                if (i == 0 || i == this.sizeX || j == 0 || j == this.sizeY || k == 0 || k == this.sizeZ) {
                    boolean placeBlock = true;
                    if (getDirection().getAxis() == EnumFacing.Axis.Z) {
                        int start = (this.boundingBox.maxX - this.boundingBox.minX) / 2 - 1;
                        int end = (this.boundingBox.maxX - this.boundingBox.minX) / 2 + 1;
                        if (i > start && i <= end && j < 3 && j > 0) {
                            if (getDirection() == EnumFacing.SOUTH && k == 0) {
                                placeBlock = false;
                            } else if (getDirection() == EnumFacing.NORTH && k == this.sizeZ) {
                                placeBlock = false;
                            }
                        }
                    } else {
                        int start = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 - 1;
                        int end = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 + 1;
                        if (k > start && k <= end && j < 3 && j > 0) {
                            if (getDirection() == EnumFacing.EAST && i == 0) {
                                placeBlock = false;
                            } else if (getDirection() == EnumFacing.WEST && i == this.sizeX) {
                                placeBlock = false;
                            }
                        }
                    }
                    if (placeBlock) {
                        this.setBlockState(worldIn, this.configuration.getBrickBlock(), i, j, k, boundingBox);
                    } else {
                        this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), i, j, k, boundingBox);
                    }
                } else if ((i == 1 && k == 1) || (i == 1 && k == this.sizeZ - 1) || (i == this.sizeX - 1 && k == 1) || (i == this.sizeX - 1 && k == this.sizeZ - 1)) {
                    this.setBlockState(worldIn, Blocks.GLOWSTONE.getDefaultState(), i, j, k, boundingBox);
                } else if (i == this.sizeX / 2 && j == 1 && k == this.sizeZ / 2) {
                    BlockPos blockpos = new BlockPos(this.getXWithOffset(i, k), this.getYWithOffset(j), this.getZWithOffset(i, k));
                    if (boundingBox.isVecInside(blockpos)) {
                        worldIn.setBlockState(blockpos, MarsBlocks.treasureChestTier2.getDefaultState().withProperty(BlockTier2TreasureChest.FACING, this.getDirection().getOpposite()), 2);
                        TileEntityTreasureChest treasureChest = (TileEntityTreasureChest) worldIn.getTileEntity(blockpos);
                        if (treasureChest != null) {
                            ResourceLocation chesttype = TABLE_TIER_2_DUNGEON;
                            if (worldIn.provider instanceof IGalacticraftWorldProvider) {
                                chesttype = ((IGalacticraftWorldProvider) worldIn.provider).getDungeonChestType();
                            }
                            treasureChest.setLootTable(chesttype, random.nextLong());
                        }
                    }
                } else {
                    this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), i, j, k, boundingBox);
                }
            }
        }
    }
    return true;
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) ResourceLocation(net.minecraft.util.ResourceLocation) TileEntityTreasureChest(micdoodle8.mods.galacticraft.core.tile.TileEntityTreasureChest) BlockPos(net.minecraft.util.math.BlockPos)

Example 48 with IGalacticraftWorldProvider

use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider 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 49 with IGalacticraftWorldProvider

use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.

the class BlockUnlitTorch method onOxygenRemoved.

@Override
public void onOxygenRemoved(World world, BlockPos pos, IBlockState state) {
    if (world.provider instanceof IGalacticraftWorldProvider) {
        EnumFacing enumfacing = state.getValue(FACING);
        world.setBlockState(pos, this.unlitVersion.getDefaultState().withProperty(FACING, enumfacing), 2);
    }
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) EnumFacing(net.minecraft.util.EnumFacing)

Example 50 with IGalacticraftWorldProvider

use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.

the class BlockUnlitTorch method checkOxygen.

private void checkOxygen(World world, BlockPos pos, IBlockState state) {
    if (world.provider instanceof IGalacticraftWorldProvider) {
        if (OxygenUtil.checkTorchHasOxygen(world, pos)) {
            this.onOxygenAdded(world, pos, state);
        } else {
            this.onOxygenRemoved(world, pos, state);
        }
    } else {
        EnumFacing enumfacing = state.getValue(FACING);
        world.setBlockState(pos, this.fallback.getDefaultState().withProperty(FACING, enumfacing), 2);
    }
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) EnumFacing(net.minecraft.util.EnumFacing)

Aggregations

IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)52 ItemStack (net.minecraft.item.ItemStack)16 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)14 BlockPos (net.minecraft.util.math.BlockPos)13 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)9 EntityPlayer (net.minecraft.entity.player.EntityPlayer)9 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)8 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)7 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)7 ResourceLocation (net.minecraft.util.ResourceLocation)7 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)6 IBlockState (net.minecraft.block.state.IBlockState)6 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 Block (net.minecraft.block.Block)5 WorldClient (net.minecraft.client.multiplayer.WorldClient)5 EnumFacing (net.minecraft.util.EnumFacing)5 WorldServer (net.minecraft.world.WorldServer)5 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)4 TileEntity (net.minecraft.tileentity.TileEntity)4