use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CallRunner method onEntityMove.
public static void onEntityMove(Entity entity, double dx, double dy, double dz) {
double movDistSq = (dx * dx) + (dy * dy) + (dz * dz);
if (movDistSq > 1000000) {
//Assume this will take us to Ship coordinates
double newX = entity.posX + dx;
double newY = entity.posY + dy;
double newZ = entity.posZ + dz;
BlockPos newPosInBlock = new BlockPos(newX, newY, newZ);
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(entity.worldObj, newPosInBlock);
if (wrapper == null) {
// System.err.println("An entity just tried moving like a millions miles an hour. Probably VW's fault, sorry about that.");
return;
}
Vector endPos = new Vector(newX, newY, newZ);
RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.wToLTransform, endPos);
dx = endPos.X - entity.posX;
dy = endPos.Y - entity.posY;
dz = endPos.Z - entity.posZ;
}
if (!EntityCollisionInjector.alterEntityMovement(entity, dx, dy, dz)) {
entity.moveEntity(dx, dy, dz);
}
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EventsClient method onDrawBlockHighlightEventLast.
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void onDrawBlockHighlightEventLast(DrawBlockHighlightEvent event) {
BlockPos pos = Minecraft.getMinecraft().objectMouseOver.getBlockPos();
if (pos != null) {
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(Minecraft.getMinecraft().theWorld, pos);
if (wrapper != null && wrapper.wrapping != null && wrapper.wrapping.renderer != null && wrapper.wrapping.centerCoord != null) {
float partialTicks = event.getPartialTicks();
Entity player = Minecraft.getMinecraft().thePlayer;
wrapper.wrapping.renderer.inverseTransform(partialTicks);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
double xOff = (player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getX();
double yOff = (player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getY();
double zOff = (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getZ();
vertexbuffer.xOffset -= xOff;
vertexbuffer.yOffset -= yOff;
vertexbuffer.zOffset -= zOff;
// GL11.glPopMatrix();
}
}
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EntityDraggable method tickAddedVelocityForWorld.
public static void tickAddedVelocityForWorld(World world) {
try {
for (int i = 0; i < world.loadedEntityList.size(); i++) {
Entity e = world.loadedEntityList.get(i);
//TODO: Maybe add a check to prevent moving entities that are fixed onto a Ship, but I like the visual effect
if (!(e instanceof PhysicsWrapperEntity) && !(e instanceof EntityCannonBall)) {
EntityDraggable draggable = getDraggableFromEntity(e);
draggable.tickAddedVelocity();
if (draggable.worldBelowFeet == null) {
if (draggable.draggableAsEntity.onGround) {
draggable.velocityAddedToPlayer.zero();
draggable.yawDifVelocity = 0;
} else {
if (draggable.draggableAsEntity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) draggable.draggableAsEntity;
if (player.isCreative() && player.capabilities.isFlying) {
draggable.velocityAddedToPlayer.multiply(.99D * .95D);
draggable.yawDifVelocity *= .95D * .95D;
}
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CustomNetHandlerPlayServer method processPlayerDigging.
@Override
public void processPlayerDigging(CPacketPlayerDigging 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.processPlayerDigging(packetIn);
RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, playerEntity);
playerEntity.rotationYaw = playerYaw;
playerEntity.rotationPitch = playerPitch;
} else {
super.processPlayerDigging(packetIn);
}
}
use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CallRunner method markBlockRangeForRenderUpdate.
public static void markBlockRangeForRenderUpdate(World world, int x1, int y1, int z1, int x2, int y2, int z2) {
//Stupid OpenComputers fix, blame those assholes
if (x2 == 1 && y1 == 0 && z2 == 1) {
x2 = x1 + 1;
x1--;
y1 = y2 - 1;
y2++;
z2 = z1 + 1;
z2--;
}
int midX = (x1 + x2) / 2;
int midY = (y1 + y2) / 2;
int midZ = (z1 + z2) / 2;
BlockPos newPos = new BlockPos(midX, midY, midZ);
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, newPos);
if (wrapper != null && wrapper.wrapping.renderer != null) {
wrapper.wrapping.renderer.updateRange(x1 - 1, y1 - 1, z1 - 1, x2 + 1, y2 + 1, z2 + 1);
}
if (wrapper == null) {
world.markBlockRangeForRenderUpdate(x1, y1, z1, x2, y2, z2);
}
}
Aggregations