Search in sources :

Example 1 with BlockVec3Dim

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim in project Galacticraft by micdoodle8.

the class TileEntityOxygenDistributor method invalidate.

@Override
public void invalidate() {
    if (!this.worldObj.isRemote) /* && this.oxygenBubble != null*/
    {
        int bubbleR = MathHelper.ceiling_double_int(bubbleSize);
        int bubbleR2 = (int) (bubbleSize * bubbleSize);
        final int xMin = this.getPos().getX() - bubbleR;
        final int xMax = this.getPos().getX() + bubbleR;
        final int yMin = this.getPos().getY() - bubbleR;
        final int yMax = this.getPos().getY() + bubbleR;
        final int zMin = this.getPos().getZ() - bubbleR;
        final int zMax = this.getPos().getZ() + bubbleR;
        for (int x = xMin; x < xMax; x++) {
            for (int z = zMin; z < zMax; z++) {
                // Doing y as the inner loop allows BlockVec3 to cache the chunks more efficiently
                for (int y = yMin; y < yMax; y++) {
                    Block block = new BlockVec3(x, y, z).getBlockID(this.worldObj);
                    if (block instanceof IOxygenReliantBlock && this.getDistanceFromServer(x, y, z) <= bubbleR2) {
                        this.worldObj.scheduleUpdate(new BlockPos(x, y, z), block, 0);
                    }
                }
            }
        }
        // this.oxygenBubble.setDead();
        TileEntityOxygenDistributor.loadedTiles.remove(new BlockVec3Dim(this));
    }
    super.invalidate();
}
Also used : IOxygenReliantBlock(micdoodle8.mods.galacticraft.api.block.IOxygenReliantBlock) Block(net.minecraft.block.Block) IOxygenReliantBlock(micdoodle8.mods.galacticraft.api.block.IOxygenReliantBlock) BlockVec3Dim(micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 2 with BlockVec3Dim

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim in project Galacticraft by micdoodle8.

the class TileEntityOxygenDistributor method readExtraNetworkedData.

@Override
public void readExtraNetworkedData(ByteBuf dataStream) {
    if (this.worldObj.isRemote) {
        // if (dataStream.readBoolean())
        // {
        // this.oxygenBubble = (EntityBubble) worldObj.getEntityByID(dataStream.readInt());
        // }
        int size = dataStream.readInt();
        if (size >= 0) {
            loadedTiles.clear();
            for (int i = 0; i < size; ++i) {
                int i1 = dataStream.readInt();
                int i2 = dataStream.readInt();
                int i3 = dataStream.readInt();
                int i4 = dataStream.readInt();
                if (i1 == -1 && i2 == -1 && i3 == -1 && i4 == -1) {
                    continue;
                }
                loadedTiles.add(new BlockVec3Dim(i1, i2, i3, i4));
            }
        }
        this.bubbleSize = dataStream.readFloat();
    }
}
Also used : BlockVec3Dim(micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim)

Example 3 with BlockVec3Dim

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim in project Galacticraft by micdoodle8.

the class EntitySpaceshipBase method onUpdate.

@Override
public void onUpdate() {
    this.ticks++;
    super.onUpdate();
    if (this.addToTelemetry) {
        this.addToTelemetry = false;
        for (BlockVec3Dim vec : new ArrayList<BlockVec3Dim>(this.telemetryList)) {
            TileEntity t1 = vec.getTileEntityNoLoad();
            if (t1 instanceof TileEntityTelemetry && !t1.isInvalid()) {
                if (((TileEntityTelemetry) t1).linkedEntity == this)
                    ((TileEntityTelemetry) t1).addTrackedEntity(this);
            }
        }
    }
    if (this.riddenByEntity != null) {
        this.riddenByEntity.fallDistance = 0.0F;
    }
    if (this.posY > (this.worldObj.provider instanceof IExitHeight ? ((IExitHeight) this.worldObj.provider).getYCoordinateToTeleport() : 1200) && this.launchPhase != EnumLaunchPhase.LANDING.ordinal()) {
        this.onReachAtmosphere();
    // if (this.worldObj.isRemote)
    // this.posY = 1 + (this.worldObj.provider instanceof IExitHeight ? ((IExitHeight) this.worldObj.provider).getYCoordinateToTeleport() : 1200);
    }
    if (this.rollAmplitude > 0) {
        this.rollAmplitude--;
    }
    if (this.shipDamage > 0) {
        this.shipDamage--;
    }
    if (!this.worldObj.isRemote) {
        if (this.posY < 0.0D) {
            this.setDead();
        } else if (this.posY > (this.worldObj.provider instanceof IExitHeight ? ((IExitHeight) this.worldObj.provider).getYCoordinateToTeleport() : 1200) + (this.launchPhase == EnumLaunchPhase.LANDING.ordinal() ? 355 : 100)) {
            if (this.riddenByEntity instanceof EntityPlayerMP) {
                GCPlayerStats stats = GCPlayerStats.get(this.riddenByEntity);
                if (stats.isUsingPlanetSelectionGui()) {
                    this.setDead();
                }
            } else
                this.setDead();
        }
        if (this.timeSinceLaunch > 50 && this.onGround) {
            this.failRocket();
        }
    }
    if (this.launchPhase == EnumLaunchPhase.UNIGNITED.ordinal()) {
        this.timeUntilLaunch = this.getPreLaunchWait();
    }
    if (this.launchPhase >= EnumLaunchPhase.LAUNCHED.ordinal()) {
        this.timeSinceLaunch++;
    } else {
        this.timeSinceLaunch = 0;
    }
    if (this.timeUntilLaunch > 0 && this.launchPhase == EnumLaunchPhase.IGNITED.ordinal()) {
        this.timeUntilLaunch--;
    }
    AxisAlignedBB box = null;
    box = this.getEntityBoundingBox().expand(0.2D, 0.2D, 0.2D);
    final List<?> var15 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, box);
    if (var15 != null && !var15.isEmpty()) {
        for (int var52 = 0; var52 < var15.size(); ++var52) {
            final Entity var17 = (Entity) var15.get(var52);
            if (var17 != this.riddenByEntity) {
                var17.applyEntityCollision(this);
            }
        }
    }
    if (this.timeUntilLaunch == 0 && this.launchPhase == EnumLaunchPhase.IGNITED.ordinal()) {
        this.setLaunchPhase(EnumLaunchPhase.LAUNCHED);
        this.onLaunch();
    }
    if (this.rotationPitch > 90) {
        this.rotationPitch = 90;
    }
    if (this.rotationPitch < -90) {
        this.rotationPitch = -90;
    }
    this.motionX = -(50 * Math.cos(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * Math.sin(this.rotationPitch * 0.01 / Constants.RADIANS_TO_DEGREES_D));
    this.motionZ = -(50 * Math.sin(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * Math.sin(this.rotationPitch * 0.01 / Constants.RADIANS_TO_DEGREES_D));
    if (this.launchPhase < EnumLaunchPhase.LAUNCHED.ordinal()) {
        this.motionX = this.motionY = this.motionZ = 0.0F;
    }
    if (this.worldObj.isRemote) {
        this.setPosition(this.posX, this.posY, this.posZ);
        if (this.shouldMoveClientSide()) {
            this.moveEntity(this.motionX, this.motionY, this.motionZ);
        }
    } else {
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
    }
    this.setRotation(this.rotationYaw, this.rotationPitch);
    if (this.worldObj.isRemote) {
        this.setPosition(this.posX, this.posY, this.posZ);
    }
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    if (!this.worldObj.isRemote && this.ticks % 3 == 0) {
        GalacticraftCore.packetPipeline.sendToDimension(new PacketDynamic(this), this.worldObj.provider.getDimensionId());
    // PacketDispatcher.sendPacketToAllInDimension(GCCorePacketManager.getPacket(GalacticraftCore.CHANNELENTITIES,
    // this, this.getNetworkedData(new ArrayList())),
    // this.worldObj.provider.getDimensionId());
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityTelemetry(micdoodle8.mods.galacticraft.core.tile.TileEntityTelemetry) ArrayList(java.util.ArrayList) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IExitHeight(micdoodle8.mods.galacticraft.api.world.IExitHeight) PacketDynamic(micdoodle8.mods.galacticraft.core.network.PacketDynamic) BlockVec3Dim(micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim)

Example 4 with BlockVec3Dim

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim in project Galacticraft by micdoodle8.

the class EntitySpaceshipBase method writeEntityToNBT.

@Override
protected void writeEntityToNBT(NBTTagCompound nbt) {
    nbt.setInteger("launchPhase", this.launchPhase + 1);
    nbt.setInteger("timeUntilLaunch", this.timeUntilLaunch);
    if (telemetryList.size() > 0) {
        NBTTagList teleNBTList = new NBTTagList();
        for (BlockVec3Dim vec : new ArrayList<BlockVec3Dim>(this.telemetryList)) {
            NBTTagCompound tag = new NBTTagCompound();
            vec.writeToNBT(tag);
            teleNBTList.appendTag(tag);
        }
        nbt.setTag("telemetryList", teleNBTList);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockVec3Dim(micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim)

Example 5 with BlockVec3Dim

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim in project Galacticraft by micdoodle8.

the class BlockBasicMoon method breakBlock.

@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    super.breakBlock(worldIn, pos, state);
    EnumBlockBasicMoon type = ((EnumBlockBasicMoon) state.getValue(BASIC_TYPE_MOON));
    if (!worldIn.isRemote && type == EnumBlockBasicMoon.MOON_TURF) {
        Map<Long, List<Footprint>> footprintChunkMap = TickHandlerServer.serverFootprintMap.get(GCCoreUtil.getDimensionID(worldIn));
        if (footprintChunkMap != null) {
            long chunkKey = ChunkCoordIntPair.chunkXZ2Int(pos.getX() >> 4, pos.getZ() >> 4);
            List<Footprint> footprintList = footprintChunkMap.get(chunkKey);
            if (footprintList != null && !footprintList.isEmpty()) {
                List<Footprint> toRemove = new ArrayList<Footprint>();
                for (Footprint footprint : footprintList) {
                    if (footprint.position.x > pos.getX() && footprint.position.x < pos.getX() + 1 && footprint.position.z > pos.getZ() && footprint.position.z < pos.getZ() + 1) {
                        toRemove.add(footprint);
                    }
                }
                if (!toRemove.isEmpty()) {
                    footprintList.removeAll(toRemove);
                }
            }
        }
        TickHandlerServer.footprintBlockChanges.add(new BlockVec3Dim(pos, GCCoreUtil.getDimensionID(worldIn)));
    }
}
Also used : Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) BlockVec3Dim(micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim)

Aggregations

BlockVec3Dim (micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim)9 ArrayList (java.util.ArrayList)3 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)3 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)2 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 TileEntity (net.minecraft.tileentity.TileEntity)2 BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 IOxygenReliantBlock (micdoodle8.mods.galacticraft.api.block.IOxygenReliantBlock)1 IExitHeight (micdoodle8.mods.galacticraft.api.world.IExitHeight)1 WorldDataSpaceRaces (micdoodle8.mods.galacticraft.core.dimension.WorldDataSpaceRaces)1 EnergyNetwork (micdoodle8.mods.galacticraft.core.energy.grid.EnergyNetwork)1 TileBaseConductor (micdoodle8.mods.galacticraft.core.energy.tile.TileBaseConductor)1 FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)1 PacketDynamic (micdoodle8.mods.galacticraft.core.network.PacketDynamic)1 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)1 TileEntityFluidTransmitter (micdoodle8.mods.galacticraft.core.tile.TileEntityFluidTransmitter)1