/*
 * Copyright 2015 Lukas Tenbrink
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package ivorius.ivtoolkit.tools;

import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.entity.EntityCreature;
import net.minecraftforge.fml.relauncher.ReflectionHelper;

import java.lang.reflect.Field;

/**
 * Created by lukas on 22.07.15.
 */
public class WorldRendererAccessor
{
    protected static Field xOffset;
    protected static Field yOffset;
    protected static Field zOffset;

    protected static Field getXOffset()
    {
        return xOffset != null
                ? xOffset
                : (xOffset = ReflectionHelper.findField(WorldRenderer.class, "xOffset", "field_179004_l"));
    }

    protected static Field getYOffset()
    {
        return yOffset != null
                ? yOffset
                : (yOffset = ReflectionHelper.findField(WorldRenderer.class, "yOffset", "field_179005_m"));
    }

    protected static Field getZOffset()
    {
        return zOffset != null
                ? zOffset
                : (zOffset = ReflectionHelper.findField(WorldRenderer.class, "zOffset", "field_179002_n"));
    }

    public static void addTranslation(WorldRenderer renderer, double x, double y, double z)
    {
        try
        {
            getXOffset().setDouble(renderer, x);
            getYOffset().setDouble(renderer, y);
            getZOffset().setDouble(renderer, z);
        }
        catch (IllegalAccessException e)
        {
            e.printStackTrace();
        }
    }
}

@@ -1815,16 +1815,40 @@
         
+renderer.setTranslation(
 getXOffs
@@ -1844,33 +1844,33 @@
 on(getXOffset().
-s
+g
 etDouble(rendere
@@ -1874,25 +1874,14 @@
 erer
-, x);%0A           
+) + x,
  get
@@ -1882,33 +1882,33 @@
 x, getYOffset().
-s
+g
 etDouble(rendere
@@ -1912,25 +1912,14 @@
 erer
-, y);%0A           
+) + y,
  get
@@ -1928,17 +1928,17 @@
 ffset().
-s
+g
 etDouble
@@ -1946,17 +1946,19 @@
 renderer
-,
+) +
  z);%0A   

Fix addTranslation.