Search in sources :

Example 21 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ShipPilotingController method getShipPlayerIsPiloting.

public static PhysicsWrapperEntity getShipPlayerIsPiloting(EntityPlayer pilot) {
    World playerWorld = pilot.worldObj;
    WorldPhysObjectManager worldManager = ValkyrienWarfareMod.physicsManager.getManagerForWorld(playerWorld);
    for (PhysicsWrapperEntity wrapperEntity : worldManager.physicsEntities) {
        if (wrapperEntity.wrapping.pilotingController.getPilotEntity() == pilot) {
            return wrapperEntity;
        }
    }
    return null;
}
Also used : WorldPhysObjectManager(ValkyrienWarfareBase.PhysicsManagement.WorldPhysObjectManager) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) World(net.minecraft.world.World)

Example 22 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ItemSystemLinker method onItemUse.

@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    IBlockState state = worldIn.getBlockState(pos);
    Block block = state.getBlock();
    NBTTagCompound stackCompound = stack.getTagCompound();
    if (stackCompound == null) {
        stackCompound = new NBTTagCompound();
        stack.setTagCompound(stackCompound);
    }
    if (block instanceof BlockHovercraftController) {
        if (!worldIn.isRemote) {
            NBTUtils.writeBlockPosToNBT("controllerPos", pos, stackCompound);
            playerIn.addChatMessage(new TextComponentString("ControllerPos set <" + pos.getX() + ":" + pos.getY() + ":" + pos.getZ() + ">"));
        } else {
            return EnumActionResult.SUCCESS;
        }
    }
    if (block instanceof BlockEtherCompressor) {
        if (!worldIn.isRemote) {
            BlockPos controllerPos = NBTUtils.readBlockPosFromNBT("controllerPos", stackCompound);
            if (controllerPos.equals(BlockPos.ORIGIN)) {
                playerIn.addChatMessage(new TextComponentString("No selected Controller"));
            } else {
                PhysicsWrapperEntity controllerWrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, controllerPos);
                PhysicsWrapperEntity engineWrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
                if (controllerWrapper != engineWrapper) {
                    playerIn.addChatMessage(new TextComponentString("Controller and Engine are on seperate ships"));
                    return EnumActionResult.SUCCESS;
                }
                TileEntity worldTile = worldIn.getTileEntity(pos);
                if (worldTile instanceof TileEntityEtherCompressor) {
                    TileEntityEtherCompressor tileEntity = (TileEntityEtherCompressor) worldTile;
                    BlockPos gravControllerPos = tileEntity.controllerPos;
                    if (gravControllerPos.equals(BlockPos.ORIGIN)) {
                        playerIn.addChatMessage(new TextComponentString("Set Controller To " + controllerPos.toString()));
                    } else {
                        playerIn.addChatMessage(new TextComponentString("Replaced controller position from: " + gravControllerPos.toString() + " to: " + controllerPos.toString()));
                    }
                    tileEntity.setController(controllerPos);
                }
            }
        } else {
            return EnumActionResult.SUCCESS;
        }
    }
    return EnumActionResult.PASS;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockHovercraftController(ValkyrienWarfareControl.Block.BlockHovercraftController) BlockEtherCompressor(ValkyrienWarfareBase.API.Block.EtherCompressor.BlockEtherCompressor) IBlockState(net.minecraft.block.state.IBlockState) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) TileEntityEtherCompressor(ValkyrienWarfareBase.API.Block.EtherCompressor.TileEntityEtherCompressor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 23 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity 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 24 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class BlockBalloonBurner method getTileEntity.

private BalloonBurnerTileEntity getTileEntity(World world, BlockPos pos, IBlockState state, Entity shipEntity) {
    PhysicsWrapperEntity wrapper = (PhysicsWrapperEntity) shipEntity;
    PhysicsObject obj = wrapper.wrapping;
    IBlockState controllerState = obj.VKChunkCache.getBlockState(pos);
    TileEntity worldTile = obj.VKChunkCache.getTileEntity(pos);
    if (worldTile == null) {
        return null;
    }
    if (worldTile instanceof BalloonBurnerTileEntity) {
        BalloonBurnerTileEntity burnerTile = (BalloonBurnerTileEntity) worldTile;
        return burnerTile;
    }
    return null;
}
Also used : BalloonBurnerTileEntity(ValkyrienWarfareControl.TileEntity.BalloonBurnerTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BalloonBurnerTileEntity(ValkyrienWarfareControl.TileEntity.BalloonBurnerTileEntity) PhysicsObject(ValkyrienWarfareBase.PhysicsManagement.PhysicsObject)

Example 25 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class BlockHovercraftController method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
    if (heldItem != null && heldItem.getItem() instanceof ItemSystemLinker) {
        return false;
    }
    if (wrapper != null) {
        if (!worldIn.isRemote) {
            if (playerIn instanceof EntityPlayerMP) {
                EntityPlayerMP player = (EntityPlayerMP) playerIn;
                int realWindowId = player.currentWindowId;
                // TODO: Fix this, I have to reset the window Id's because there is no container on client side, resulting in the client never changing its window id
                player.currentWindowId = player.inventoryContainer.windowId - 1;
                player.openGui(ValkyrienWarfareControlMod.instance, ControlGUIEnum.HoverCraftController.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
                player.currentWindowId = realWindowId;
            // player.openContainer = playerIn.inventoryContainer;
            }
        // ModContainer mc = FMLCommonHandler.instance().findContainerFor(ValkyrienWarfareControlMod.instance);
        // if (playerIn instanceof EntityPlayerMP && !(playerIn instanceof FakePlayer))
        // {
        // EntityPlayerMP entityPlayerMP = (EntityPlayerMP) playerIn;
        // Container remoteGuiContainer = NetworkRegistry.INSTANCE.getRemoteGuiContainer(mc, entityPlayerMP, ControlGUIEnum.HoverCraftController.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
        // if (remoteGuiContainer != null)
        // {
        // entityPlayerMP.getNextWindowId();
        // entityPlayerMP.closeContainer();
        // int windowId = entityPlayerMP.currentWindowId;
        // entityPlayerMP.openContainer = remoteGuiContainer;
        // entityPlayerMP.openContainer = entityPlayerMP.inventoryContainer;
        //// entityPlayerMP.openContainer.windowId = windowId;
        //// entityPlayerMP.openContainer.addListener(entityPlayerMP);
        // net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(playerIn, playerIn.openContainer));
        // }
        // }
        }
        return true;
    }
    return false;
}
Also used : ItemSystemLinker(ValkyrienWarfareControl.Item.ItemSystemLinker) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Aggregations

PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)69 BlockPos (net.minecraft.util.math.BlockPos)29 Vector (ValkyrienWarfareBase.API.Vector)28 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 IBlockState (net.minecraft.block.state.IBlockState)9 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)9 TextComponentString (net.minecraft.util.text.TextComponentString)9 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)8 Vec3d (net.minecraft.util.math.Vec3d)7 WorldPhysObjectManager (ValkyrienWarfareBase.PhysicsManagement.WorldPhysObjectManager)6 Block (net.minecraft.block.Block)6 Entity (net.minecraft.entity.Entity)6 TileEntity (net.minecraft.tileentity.TileEntity)6 IThreadListener (net.minecraft.util.IThreadListener)5 World (net.minecraft.world.World)5 Quaternion (ValkyrienWarfareBase.Math.Quaternion)4 ArrayList (java.util.ArrayList)4 RayTraceResult (net.minecraft.util.math.RayTraceResult)4 EntityPolygon (ValkyrienWarfareBase.Collision.EntityPolygon)3 Polygon (ValkyrienWarfareBase.Collision.Polygon)3