Search in sources :

Example 1 with IThreadListener

use of net.minecraft.util.IThreadListener in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class SetShipPilotMessageHandler method onMessage.

@Override
public IMessage onMessage(final SetShipPilotMessage message, final MessageContext ctx) {
    IThreadListener mainThread = Minecraft.getMinecraft();
    mainThread.addScheduledTask(new Runnable() {

        @Override
        public void run() {
            UUID entityId = message.entityUniqueID;
            if (entityId.getLeastSignificantBits() == 0L && entityId.getMostSignificantBits() == 0L) {
                ClientPilotingManager.setPilotedWrapperEntity(null);
            //					System.out.println("got set to null");
            } else {
                Entity foundEntity = null;
                for (Entity entity : Minecraft.getMinecraft().theWorld.getLoadedEntityList()) {
                    if (entity.entityUniqueID.equals(entityId)) {
                        ClientPilotingManager.setPilotedWrapperEntity((PhysicsWrapperEntity) entity);
                        //							System.out.println("Found the Pilot on client side");
                        foundEntity = entity;
                    }
                }
                if (foundEntity == null) {
                    ClientPilotingManager.setPilotedWrapperEntity(null);
                }
            }
        }
    });
    return null;
}
Also used : Entity(net.minecraft.entity.Entity) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) IThreadListener(net.minecraft.util.IThreadListener) UUID(java.util.UUID)

Example 2 with IThreadListener

use of net.minecraft.util.IThreadListener in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EntityFixMessageHandler method onMessage.

@Override
public IMessage onMessage(final EntityFixMessage message, MessageContext ctx) {
    IThreadListener mainThread = Minecraft.getMinecraft();
    mainThread.addScheduledTask(new Runnable() {

        @Override
        public void run() {
            PhysicsWrapperEntity toFixOn = (PhysicsWrapperEntity) Minecraft.getMinecraft().theWorld.getEntityByID(message.shipId);
            if (toFixOn != null) {
                if (message.isFixing) {
                    toFixOn.wrapping.fixEntityUUID(message.entityUUID, message.localPosition);
                } else {
                    toFixOn.wrapping.removeEntityUUID(message.entityUUID);
                }
            }
        }
    });
    return null;
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) IThreadListener(net.minecraft.util.IThreadListener)

Example 3 with IThreadListener

use of net.minecraft.util.IThreadListener in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class PhysWrapperPositionHandler method onMessage.

@Override
public IMessage onMessage(final PhysWrapperPositionMessage message, MessageContext ctx) {
    if (Minecraft.getMinecraft().thePlayer == null) {
        return null;
    }
    IThreadListener mainThread = Minecraft.getMinecraft();
    mainThread.addScheduledTask(new Runnable() {

        @Override
        public void run() {
            Entity ent = Minecraft.getMinecraft().theWorld.getEntityByID(message.entityID);
            if (ent != null && ent instanceof PhysicsWrapperEntity) {
                PhysicsWrapperEntity wrapper = (PhysicsWrapperEntity) ent;
                wrapper.wrapping.coordTransform.stack.pushMessage(message);
            // wrapper.wrapping.centerCoord = message.centerOfMass;
            //
            // wrapper.posX = message.posX;
            // wrapper.posY = message.posY;
            // wrapper.posZ = message.posZ;
            //
            // wrapper.pitch = message.pitch;
            // wrapper.yaw = message.yaw;
            // wrapper.roll = message.roll;
            //
            // wrapper.wrapping.coordTransform.updateAllTransforms();
            }
        }
    });
    return null;
}
Also used : Entity(net.minecraft.entity.Entity) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) IThreadListener(net.minecraft.util.IThreadListener)

Example 4 with IThreadListener

use of net.minecraft.util.IThreadListener in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class HovercraftControllerGUIInputHandler method onMessage.

@Override
public IMessage onMessage(final HovercraftControllerGUIInputMessage message, final MessageContext ctx) {
    IThreadListener mainThread = ctx.getServerHandler().serverController;
    mainThread.addScheduledTask(new Runnable() {

        @Override
        public void run() {
            PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(ctx.getServerHandler().playerEntity.worldObj, message.tilePos);
            TileEntity tileEnt = wrapper.wrapping.VKChunkCache.getTileEntity(message.tilePos);
            if (tileEnt != null) {
                if (tileEnt instanceof TileEntityHoverController) {
                    ((TileEntityHoverController) tileEnt).handleGUIInput(message, ctx);
                }
            } else {
                System.out.println("Player: " + ctx.getServerHandler().playerEntity.getName() + " sent a broken packet");
            }
        }
    });
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) IThreadListener(net.minecraft.util.IThreadListener) TileEntityHoverController(ValkyrienWarfareControl.TileEntity.TileEntityHoverController)

Example 5 with IThreadListener

use of net.minecraft.util.IThreadListener in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class PilotControlsMessageHandler method onMessage.

@Override
public IMessage onMessage(final PilotControlsMessage message, final MessageContext ctx) {
    IThreadListener mainThread = ctx.getServerHandler().serverController;
    mainThread.addScheduledTask(new Runnable() {

        @Override
        public void run() {
            World worldObj = ctx.getServerHandler().playerEntity.worldObj;
            if (ValkyrienWarfareMod.physicsManager.getManagerForWorld(worldObj) != null) {
                UUID shipId = message.shipFor;
                for (PhysicsWrapperEntity entity : ValkyrienWarfareMod.physicsManager.getManagerForWorld(worldObj).physicsEntities) {
                    if (entity.getUniqueID().equals(shipId)) {
                        entity.wrapping.pilotingController.receivePilotControlsMessage(message, ctx.getServerHandler().playerEntity);
                    }
                }
            }
        }
    });
    return null;
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) IThreadListener(net.minecraft.util.IThreadListener) World(net.minecraft.world.World) UUID(java.util.UUID)

Aggregations

PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)5 IThreadListener (net.minecraft.util.IThreadListener)5 UUID (java.util.UUID)2 Entity (net.minecraft.entity.Entity)2 TileEntityHoverController (ValkyrienWarfareControl.TileEntity.TileEntityHoverController)1 TileEntity (net.minecraft.tileentity.TileEntity)1 World (net.minecraft.world.World)1