Java Code Examples for net.minecraft.util.Vec3#rotateAroundZ()

The following examples show how to use net.minecraft.util.Vec3#rotateAroundZ() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityShip.java    From archimedes-ships with MIT License 4 votes vote down vote up
public void updateRiderPosition(Entity entity, int seatx, int seaty, int seatz, int flags)
{
	if (entity != null)
	{
		float yaw = (float) Math.toRadians(rotationYaw);
		float pitch = (float) Math.toRadians(rotationPitch);
		
		int x1 = seatx, y1 = seaty, z1 = seatz;
		if ((flags & 1) == 1)
		{
			if (frontDirection == 0)
			{
				z1 -= 1;
			} else if (frontDirection == 1)
			{
				x1 += 1;
			} else if (frontDirection == 2)
			{
				z1 += 1;
			} else if (frontDirection == 3)
			{
				x1 -= 1;
			}
			
			Block block = shipChunk.getBlock(x1, MathHelper.floor_double(y1 + getMountedYOffset() + entity.getYOffset()), z1);
			if (block.isOpaqueCube())
			{
				x1 = seatx;
				y1 = seaty;
				z1 = seatz;
			}
		}
		
		double yoff = (flags & 2) == 2 ? 0d : getMountedYOffset();
		Vec3 vec = Vec3.createVectorHelper(x1 - shipChunk.getCenterX() + 0.5d, y1 - shipChunk.minY() + yoff, z1 - shipChunk.getCenterZ() + 0.5d);
		switch (frontDirection)
		{
		case 0:
			vec.rotateAroundZ(-pitch);
			break;
		case 1:
			vec.rotateAroundX(pitch);
			break;
		case 2:
			vec.rotateAroundZ(pitch);
			break;
		case 3:
			vec.rotateAroundX(-pitch);
			break;
		}
		vec.rotateAroundY(yaw);
		
		entity.setPosition(posX + vec.xCoord, posY + vec.yCoord + entity.getYOffset(), posZ + vec.zCoord);
	}
}
 
Example 2
Source File: GuiUnitProgrammer.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
private void showFlow(){
    GL11.glLineWidth(1);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBegin(GL11.GL_LINES);

    for(IProgWidget widget : progWidgets) {
        if(widget instanceof IJump) {
            List<String> jumpLocations = ((IJump)widget).getPossibleJumpLocations();
            if(jumpLocations != null) {
                for(String jumpLocation : jumpLocations) {
                    if(jumpLocation != null) {
                        for(IProgWidget w : progWidgets) {
                            if(w instanceof ILabel) {
                                String label = ((ILabel)w).getLabel();
                                if(label != null && jumpLocation.equals(label)) {
                                    int x1 = widget.getX() + widget.getWidth() / 4;
                                    int y1 = widget.getY() + widget.getHeight() / 4;
                                    int x2 = w.getX() + w.getWidth() / 4;
                                    int y2 = w.getY() + w.getHeight() / 4;
                                    double midX = (x2 + x1) / 2D;
                                    double midY = (y2 + y1) / 2D;
                                    GL11.glVertex3d(guiLeft + x1, guiTop + y1, zLevel);
                                    GL11.glVertex3d(guiLeft + x2, guiTop + y2, zLevel);
                                    Vec3 arrowVec = Vec3.createVectorHelper(x1 - x2, y1 - y2, 0).normalize();
                                    float arrowAngle = (float)Math.toRadians(30);
                                    float arrowSize = 5;
                                    arrowVec.xCoord *= arrowSize;
                                    arrowVec.yCoord *= arrowSize;
                                    arrowVec.rotateAroundZ(arrowAngle);
                                    GL11.glVertex3d(guiLeft + midX, guiTop + midY, zLevel);
                                    GL11.glVertex3d(guiLeft + midX + arrowVec.xCoord, guiTop + midY + arrowVec.yCoord, zLevel);
                                    arrowVec.rotateAroundZ(-2 * arrowAngle);
                                    GL11.glVertex3d(guiLeft + midX, guiTop + midY, zLevel);
                                    GL11.glVertex3d(guiLeft + midX + arrowVec.xCoord, guiTop + midY + arrowVec.yCoord, zLevel);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
}