Search in sources :

Example 6 with PhysicsWrapperEntity

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

the class EventsCommon method onBlockBreak.

@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent event) {
    if (!event.getWorld().isRemote) {
        PhysicsWrapperEntity physObj = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(event.getWorld(), event.getPos());
        if (physObj != null) {
            if (ValkyrienWarfareMod.runAirshipPermissions && !(physObj.wrapping.creator.equals(event.getPlayer().entityUniqueID.toString()) || physObj.wrapping.allowedUsers.contains(event.getPlayer().entityUniqueID.toString()))) {
                event.getPlayer().addChatMessage(new TextComponentString("You need to be added to the airship to do that!" + (physObj.wrapping.creator == null || physObj.wrapping.creator.trim().isEmpty() ? " Try using \"/airshipSettings claim\"!" : "")));
                event.setCanceled(true);
                return;
            }
            if (physObj.wrapping.shipType == ShipType.Oribtal) {
            //Do not let it break
            }
        }
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 7 with PhysicsWrapperEntity

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

the class CustomNetHandlerPlayServer method processUpdateSign.

@Override
public void processUpdateSign(CPacketUpdateSign packetIn) {
    BlockPos packetPos = packetIn.getPosition();
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(playerEntity.worldObj, packetPos);
    if (playerEntity.interactionManager.getBlockReachDistance() != dummyBlockReachDist) {
        lastGoodBlockReachDist = playerEntity.interactionManager.getBlockReachDistance();
    }
    if (wrapper != null) {
        playerEntity.interactionManager.setBlockReachDistance(dummyBlockReachDist);
        ticksSinceLastTry = 0;
    }
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    if (wrapper != null && wrapper.wrapping.coordTransform != null) {
        float playerYaw = playerEntity.rotationYaw;
        float playerPitch = playerEntity.rotationPitch;
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.wToLTransform, wrapper.wrapping.coordTransform.wToLRotation, playerEntity);
        super.processUpdateSign(packetIn);
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, playerEntity);
        playerEntity.rotationYaw = playerYaw;
        playerEntity.rotationPitch = playerPitch;
    } else {
        super.processUpdateSign(packetIn);
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 8 with PhysicsWrapperEntity

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

the class CustomNetHandlerPlayServer method processRightClickBlock.

@Override
public void processRightClickBlock(CPacketPlayerTryUseItemOnBlock packetIn) {
    BlockPos packetPos = packetIn.getPos();
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(playerEntity.worldObj, packetPos);
    if (playerEntity.interactionManager.getBlockReachDistance() != dummyBlockReachDist) {
        lastGoodBlockReachDist = playerEntity.interactionManager.getBlockReachDistance();
    }
    if (wrapper != null) {
        playerEntity.interactionManager.setBlockReachDistance(dummyBlockReachDist);
        ticksSinceLastTry = 0;
    }
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    if (wrapper != null && wrapper.wrapping.coordTransform != null) {
        float playerYaw = playerEntity.rotationYaw;
        float playerPitch = playerEntity.rotationPitch;
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.wToLTransform, wrapper.wrapping.coordTransform.wToLRotation, playerEntity);
        if (playerEntity.getHeldItem(packetIn.getHand()) != null && playerEntity.getHeldItem(packetIn.getHand()).getItem() instanceof ItemBucket) {
            playerEntity.interactionManager.setBlockReachDistance(lastGoodBlockReachDist);
        }
        try {
            super.processRightClickBlock(packetIn);
        } catch (Exception e) {
        }
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, playerEntity);
        playerEntity.rotationYaw = playerYaw;
        playerEntity.rotationPitch = playerPitch;
    } else {
        super.processRightClickBlock(packetIn);
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) ItemBucket(net.minecraft.item.ItemBucket)

Example 9 with PhysicsWrapperEntity

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

the class ValkyrienWarfareWorldEventListener method sendBlockBreakProgress.

@Override
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {
    if (!worldObj.isRemote) {
        for (EntityPlayer entityplayermp : worldObj.playerEntities) {
            if (entityplayermp != null && entityplayermp.getEntityId() != breakerId) {
                Vector posVector = new Vector(pos.getX(), pos.getY(), pos.getZ());
                PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldObj, pos);
                if (wrapper != null) {
                    RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, posVector);
                }
                double d0 = posVector.X - entityplayermp.posX;
                double d1 = posVector.Y - entityplayermp.posY;
                double d2 = posVector.Z - entityplayermp.posZ;
                if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
                    ((EntityPlayerMP) entityplayermp).connection.sendPacket(new SPacketBlockBreakAnim(breakerId, pos, progress));
                }
            }
        }
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SPacketBlockBreakAnim(net.minecraft.network.play.server.SPacketBlockBreakAnim) Vector(ValkyrienWarfareBase.API.Vector)

Example 10 with PhysicsWrapperEntity

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

the class BalloonBurnerTileEntity method getBlockForcePosition.

public Vector getBlockForcePosition(World world, BlockPos pos, IBlockState state, Entity shipEntity, double secondsToApply) {
    if (balloon == null) {
        PhysicsWrapperEntity wrapper = (PhysicsWrapperEntity) shipEntity;
        balloon = wrapper.wrapping.balloonManager.getProcessorAbovePos(pos);
    }
    if (balloon != null) {
        return balloon.currentBalloonCenter;
    }
    return null;
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)

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