Search in sources :

Example 16 with IGalacticraftWorldProvider

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

the class TileEntitySolarArrayController method update.

@Override
public void update() {
    if (!this.initialised) {
        this.storage.setCapacity(50000);
        this.initialised = true;
    }
    if (!this.world.isRemote) {
        this.receiveEnergyGC(null, this.generateWatts, false);
        EnumSet<EnumFacing> outputDirections = EnumSet.noneOf(EnumFacing.class);
        outputDirections.addAll(Arrays.asList(EnumFacing.HORIZONTALS));
        outputDirections.removeAll(this.getElectricalOutputDirections());
        BlockVec3 thisVec = new BlockVec3(this);
        solarArray.clear();
        for (EnumFacing direction : outputDirections) {
            TileEntity tileAdj = thisVec.getTileEntityOnSide(this.world, direction);
            if (tileAdj != null) {
                if (tileAdj instanceof INetworkProvider) {
                    if (tileAdj instanceof ITransmitter) {
                        if (((ITransmitter) tileAdj).canConnect(direction.getOpposite(), NetworkType.SOLAR_MODULE)) {
                            if (((INetworkProvider) tileAdj).getNetwork() instanceof SolarModuleNetwork) {
                                solarArray.addAll(((SolarModuleNetwork) ((INetworkProvider) tileAdj).getNetwork()).getTransmitters());
                            }
                        }
                    } else {
                        if (((INetworkProvider) tileAdj).getNetwork() instanceof SolarModuleNetwork) {
                            solarArray.addAll(((SolarModuleNetwork) ((INetworkProvider) tileAdj).getNetwork()).getTransmitters());
                        }
                    }
                }
            }
        }
    }
    super.update();
    if (!this.world.isRemote) {
        this.recharge(this.getInventory().get(0));
        if (this.disableCooldown > 0) {
            this.disableCooldown--;
        }
        if (!this.getDisabled(0) && this.ticks % 20 == 0) {
            this.solarStrength = 0;
            int arraySizeWithinRange = 0;
            if (this.world.isDaytime() && (this.world.provider instanceof IGalacticraftWorldProvider || !this.world.isRaining() && !this.world.isThundering())) {
                for (ITransmitter transmitter : solarArray) {
                    TileEntity tile = (TileEntity) transmitter;
                    Vec3i diff = tile.getPos().subtract(this.getPos());
                    if (Math.abs(diff.getX()) <= 16 && diff.getY() == 0 && Math.abs(diff.getZ()) <= 16) {
                        arraySizeWithinRange++;
                        if (this.world.canBlockSeeSky(tile.getPos())) {
                            boolean valid = true;
                            for (int y = this.getPos().getY() + 1; y < 256; y++) {
                                IBlockState state = this.world.getBlockState(this.getPos().add(0, y, 0));
                                if (state.getBlock().isOpaqueCube(state)) {
                                    valid = false;
                                    break;
                                }
                            }
                            if (valid) {
                                this.solarStrength++;
                            }
                        }
                    }
                }
            }
            connectedInfo = solarStrength << 16 | arraySizeWithinRange;
        }
    }
    float angle = this.world.getCelestialAngle(1.0F) - 0.7845194F < 0 ? 1.0F - 0.7845194F : -0.7845194F;
    float celestialAngle = (this.world.getCelestialAngle(1.0F) + angle) * 360.0F;
    if (!(this.world.provider instanceof WorldProviderSpaceStation))
        celestialAngle += 12.5F;
    if (this.world.provider instanceof WorldProviderVenus)
        celestialAngle = 180F - celestialAngle;
    celestialAngle %= 360;
    boolean isDaytime = this.world.isDaytime() && (celestialAngle < 180.5F || celestialAngle > 359.5F) || this.world.provider instanceof WorldProviderSpaceStation;
    if (!this.world.isRemote) {
        int generated = this.getGenerate();
        if (generated > 0) {
            this.generateWatts = Math.min(Math.max(generated, 0), TileEntitySolarArrayController.MAX_GENERATE_WATTS);
        } else {
            this.generateWatts = 0;
        }
    }
    this.produce();
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) EnumFacing(net.minecraft.util.EnumFacing) ITransmitter(micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter) INetworkProvider(micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider) TileEntity(net.minecraft.tileentity.TileEntity) WorldProviderSpaceStation(micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3) WorldProviderVenus(micdoodle8.mods.galacticraft.planets.venus.dimension.WorldProviderVenus)

Example 17 with IGalacticraftWorldProvider

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

the class BlockUnlitTorch method onOxygenAdded.

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

Example 18 with IGalacticraftWorldProvider

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

the class TileEntityOxygenDetector method update.

@Override
public void update() {
    if (!this.world.isRemote && ++this.ticks == 50) {
        this.ticks = 0;
        if (this.getBlockType() instanceof BlockOxygenDetector) {
            boolean oxygenFound = false;
            if (this.world.provider instanceof IGalacticraftWorldProvider && !((IGalacticraftWorldProvider) this.world.provider).hasBreathableAtmosphere()) {
                oxygenFound = OxygenUtil.isAABBInBreathableAirBlock(this.world, this.oxygenSearch, false);
            } else {
                for (EnumFacing side : EnumFacing.VALUES) {
                    BlockPos offset = this.pos.offset(side, 1);
                    IBlockState bs = this.world.getBlockState(offset);
                    if (!bs.getBlock().isSideSolid(bs, world, offset, side.getOpposite())) {
                        oxygenFound = true;
                        break;
                    }
                }
            }
            ((BlockOxygenDetector) this.blockType).updateOxygenState(this.world, this.getPos(), oxygenFound);
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) BlockOxygenDetector(micdoodle8.mods.galacticraft.core.blocks.BlockOxygenDetector)

Example 19 with IGalacticraftWorldProvider

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

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

the class LayerThermalPadding method renderArmorLayer.

private void renderArmorLayer(EntityLivingBase entityLivingBaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, EntityEquipmentSlot slotIn) {
    ItemStack itemstack = this.getItemStackFromSlot(entityLivingBaseIn, slotIn);
    if (itemstack != null) {
        ModelBiped model = this.getModelFromSlot(slotIn);
        model.setModelAttributes(this.renderer.getMainModel());
        model.setLivingAnimations(entityLivingBaseIn, limbSwing, limbSwingAmount, partialTicks);
        this.setModelSlotVisible(model, slotIn);
        this.renderer.bindTexture(itemstack.getItem() instanceof ItemThermalPaddingTier2 ? RenderPlayerGC.thermalPaddingTexture1_T2 : RenderPlayerGC.thermalPaddingTexture1);
        model.render(entityLivingBaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
        // Start alpha render
        GlStateManager.disableLighting();
        Minecraft.getMinecraft().renderEngine.bindTexture(RenderPlayerGC.thermalPaddingTexture0);
        GlStateManager.enableAlpha();
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        float time = entityLivingBaseIn.ticksExisted / 10.0F;
        float sTime = (float) Math.sin(time) * 0.5F + 0.5F;
        float r = 0.2F * sTime;
        float g = 1.0F * sTime;
        float b = 0.2F * sTime;
        if (entityLivingBaseIn.world.provider instanceof IGalacticraftWorldProvider) {
            float modifier = ((IGalacticraftWorldProvider) entityLivingBaseIn.world.provider).getThermalLevelModifier();
            if (modifier > 0) {
                b = g;
                g = r;
            } else if (modifier < 0) {
                r = g;
                g = b;
            }
        }
        GlStateManager.color(r, g, b, 0.4F * sTime);
        model.render(entityLivingBaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
        GlStateManager.color(1, 1, 1, 1);
        GlStateManager.disableBlend();
        GlStateManager.enableAlpha();
        GlStateManager.enableLighting();
    }
}
Also used : ModelBiped(net.minecraft.client.model.ModelBiped) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) ItemThermalPaddingTier2(micdoodle8.mods.galacticraft.planets.venus.items.ItemThermalPaddingTier2) ItemStack(net.minecraft.item.ItemStack)

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