Search in sources :

Example 1 with PacketDynamic

use of micdoodle8.mods.galacticraft.core.network.PacketDynamic 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 2 with PacketDynamic

use of micdoodle8.mods.galacticraft.core.network.PacketDynamic in project Galacticraft by micdoodle8.

the class TileEntityArclamp method onLoad.

@Override
public void onLoad() {
    this.thisPos = new Vec3(this.getPos().getX() + 0.5D, this.getPos().getY() + 0.5D, this.getPos().getZ() + 0.5D);
    this.ticks = 0;
    this.thisAABB = null;
    if (this.worldObj.isRemote) {
        this.buckets = bucketsClient;
        this.usingBuckets = usingBucketsClient;
        if (lightUpdateBlockListClient == null) {
            lightUpdateBlockListClient = new int[SIZELIST];
        }
        this.lightUpdateBlockList = lightUpdateBlockListClient;
        this.usingLightList = usingLightListClient;
        this.clientOnLoad();
        GalacticraftCore.packetPipeline.sendToServer(new PacketDynamic(this));
    } else {
        this.buckets = bucketsServer;
        this.usingBuckets = usingBucketsServer;
        if (lightUpdateBlockListServer == null) {
            lightUpdateBlockListServer = new int[SIZELIST];
        }
        this.lightUpdateBlockList = lightUpdateBlockListServer;
        this.usingLightList = usingLightListServer;
        this.isActive = this.pos.getX() >= -30000000 + 32 && this.pos.getZ() >= -30000000 + 32 && this.pos.getX() < 30000000 - 32 && this.pos.getZ() < 30000000 - 32;
    }
}
Also used : BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3) Vec3(net.minecraft.util.Vec3) PacketDynamic(micdoodle8.mods.galacticraft.core.network.PacketDynamic)

Example 3 with PacketDynamic

use of micdoodle8.mods.galacticraft.core.network.PacketDynamic in project Galacticraft by micdoodle8.

the class TileEntityFluidTank method getDescriptionPacket.

@Override
public Packet getDescriptionPacket() {
    NBTTagCompound nbt = new NBTTagCompound();
    nbt.setString("net-type", "desc-packet");
    PacketDynamic packet = new PacketDynamic(this);
    ByteBuf buf = Unpooled.buffer();
    packet.encodeInto(buf);
    byte[] bytes = new byte[buf.readableBytes()];
    buf.readBytes(bytes);
    nbt.setByteArray("net-data", bytes);
    S35PacketUpdateTileEntity tileUpdate = new S35PacketUpdateTileEntity(getPos(), 0, nbt);
    return tileUpdate;
}
Also used : S35PacketUpdateTileEntity(net.minecraft.network.play.server.S35PacketUpdateTileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PacketDynamic(micdoodle8.mods.galacticraft.core.network.PacketDynamic) ByteBuf(io.netty.buffer.ByteBuf)

Example 4 with PacketDynamic

use of micdoodle8.mods.galacticraft.core.network.PacketDynamic in project Galacticraft by micdoodle8.

the class TileEntityFluidTank method onDataPacket.

@Override
@SideOnly(Side.CLIENT)
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
    if (!worldObj.isRemote) {
        return;
    }
    if (pkt.getNbtCompound() == null) {
        throw new RuntimeException("[GC] Missing NBTTag compound!");
    }
    NBTTagCompound nbt = pkt.getNbtCompound();
    try {
        if ("desc-packet".equals(nbt.getString("net-type"))) {
            byte[] bytes = nbt.getByteArray("net-data");
            ByteBuf data = Unpooled.wrappedBuffer(bytes);
            PacketDynamic packet = new PacketDynamic();
            packet.decodeInto(data);
            packet.handleClientSide(FMLClientHandler.instance().getClientPlayerEntity());
        }
    } catch (Throwable t) {
        throw new RuntimeException("[GC] Failed to read a packet! (" + nbt.getTag("net-type") + ", " + nbt.getTag("net-data"), t);
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ByteBuf(io.netty.buffer.ByteBuf) PacketDynamic(micdoodle8.mods.galacticraft.core.network.PacketDynamic) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with PacketDynamic

use of micdoodle8.mods.galacticraft.core.network.PacketDynamic in project Galacticraft by micdoodle8.

the class TileEntityFluidTank method update.

@Override
public void update() {
    super.update();
    if (fluidTank.getFluid() != null) {
        moveFluidDown();
    }
    if (!this.worldObj.isRemote && updateClient && delayTimer.markTimeIfDelay(this.worldObj)) {
        PacketDynamic packet = new PacketDynamic(this);
        GalacticraftCore.packetPipeline.sendToAllAround(packet, new NetworkRegistry.TargetPoint(GCCoreUtil.getDimensionID(this.worldObj), getPos().getX(), getPos().getY(), getPos().getZ(), this.getPacketRange()));
        this.updateClient = false;
    }
}
Also used : NetworkRegistry(net.minecraftforge.fml.common.network.NetworkRegistry) PacketDynamic(micdoodle8.mods.galacticraft.core.network.PacketDynamic)

Aggregations

PacketDynamic (micdoodle8.mods.galacticraft.core.network.PacketDynamic)10 ByteBuf (io.netty.buffer.ByteBuf)2 Entity (net.minecraft.entity.Entity)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 TileEntity (net.minecraft.tileentity.TileEntity)2 NetworkRegistry (net.minecraftforge.fml.common.network.NetworkRegistry)2 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)1 BlockVec3Dim (micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim)1 IExitHeight (micdoodle8.mods.galacticraft.api.world.IExitHeight)1 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)1 PacketDynamicInventory (micdoodle8.mods.galacticraft.core.network.PacketDynamicInventory)1 TileEntityTelemetry (micdoodle8.mods.galacticraft.core.tile.TileEntityTelemetry)1 WorldProviderAsteroids (micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids)1 TileEntityMinerBase (micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityMinerBase)1 Block (net.minecraft.block.Block)1 EntityItem (net.minecraft.entity.item.EntityItem)1