package net.wizardsoflua.lua.classes.scan;

import com.google.auto.service.AutoService;

import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.wizardsoflua.lua.classes.DeclareLuaClass;
import net.wizardsoflua.lua.classes.DelegatorLuaClass;
import net.wizardsoflua.lua.classes.common.LuaInstance;
import net.wizardsoflua.lua.classes.spi.DeclaredLuaClass;

@AutoService(DeclaredLuaClass.class)
@DeclareLuaClass (name = BlockHitClass.NAME)
public class BlockHitClass
    extends DelegatorLuaClass<RayTraceResult, BlockHitClass.Proxy<RayTraceResult>> {
  public static final String NAME = "BlockHit";

  @Override
  public Proxy<RayTraceResult> toLua(RayTraceResult javaObj) {
    return new Proxy<>(this, javaObj);
  }

  public static class Proxy<D extends RayTraceResult> extends LuaInstance<D> {
    public Proxy(DelegatorLuaClass<?, ?> luaClass, D delegate) {
      super(luaClass, delegate);
      addImmutable("hitVec", getConverters().toLuaNullable(delegate.hitVec));
      addImmutable("pos", getConverters().toLuaNullable(new Vec3d(delegate.getBlockPos())));
      addImmutable("sideHit", getConverters().toLuaNullable(delegate.sideHit));
    }

    @Override
    public boolean isTransferable() {
      return true;
    }
  }
}

@@ -81,16 +81,94 @@
 ervice;%0A
+import net.minecraft.util.EnumFacing;%0Aimport net.minecraft.util.math.BlockPos;
 %0Aimport 
@@ -260,103 +260,429 @@
 net.
-wizardsoflua.lua.classes.DeclareLuaClass;%0Aimport net.wizardsoflua.lua.classes.DelegatorLuaClass
+sandius.rembulan.Table;%0Aimport net.wizardsoflua.annotation.GenerateLuaClassTable;%0Aimport net.wizardsoflua.annotation.GenerateLuaDoc;%0Aimport net.wizardsoflua.annotation.GenerateLuaInstanceTable;%0Aimport net.wizardsoflua.annotation.LuaProperty;%0Aimport net.wizardsoflua.extension.api.inject.Resource;%0Aimport net.wizardsoflua.extension.spell.api.resource.LuaConverters;%0Aimport net.wizardsoflua.extension.spell.spi.LuaConverter
 ;%0Aim
@@ -719,15 +719,8 @@
 ses.
-common.
 LuaI
@@ -768,111 +768,338 @@
 ses.
-spi.DeclaredLuaClass;%0A%0A@AutoService(DeclaredLuaClass.class)%0A@DeclareLuaClass (name = BlockHitClass.NAME
+common.Delegator;%0Aimport net.wizardsoflua.lua.extension.util.BasicLuaClass;%0Aimport net.wizardsoflua.lua.extension.util.LuaClassAttributes;%0A%0A@AutoService(LuaConverter.class)%0A@LuaClassAttributes(name = BlockHitClass.NAME)%0A@GenerateLuaClassTable(instance = BlockHitClass.Instance.class)%0A@GenerateLuaDoc(subtitle = %22What Lies in View%22
 )%0Apu
@@ -1122,20 +1122,16 @@
 HitClass
-%0A   
  extends
@@ -1131,25 +1131,21 @@
 extends 
-Delegator
+Basic
 LuaClass
@@ -1175,36 +1175,26 @@
 itClass.
-Proxy%3CRayTraceResult
+Instance%3C?
 %3E%3E %7B%0A  p
@@ -1242,57 +1242,226 @@
 t%22;%0A
-%0A  @Override%0A  public Proxy%3CRayTraceResult%3E toLua
+  @Resource%0A  private LuaConverters converters;%0A%0A  @Override%0A  protected Table createRawTable() %7B%0A    return new BlockHitClassTable%3C%3E(this, converters);%0A  %7D%0A%0A  @Override%0A  protected Delegator%3CInstance%3C?%3E%3E toLuaInstance
 (Ray
@@ -1476,19 +1476,24 @@
 ult java
-Obj
+Instance
 ) %7B%0A    
@@ -1507,36 +1507,124 @@
 new 
-Proxy%3C%3E(this, javaObj);%0A  %7D%0A
+BlockHitClassInstanceTable%3C%3E(new Instance%3C%3E(javaInstance), getTable(), converters);%0A  %7D%0A%0A  @GenerateLuaInstanceTable
 %0A  p
@@ -1642,21 +1642,24 @@
 c class 
-Proxy
+Instance
 %3CD exten
@@ -1717,48 +1717,17 @@
 lic 
-Proxy(DelegatorLuaClass%3C?, ?%3E luaClass, 
+Instance(
 D de
@@ -1752,18 +1752,8 @@
 per(
-luaClass, 
 dele
@@ -1767,63 +1767,72 @@
     
-  addImmutable(%22hitVec%22,
+%7D%0A%0A    @LuaProperty%0A    public Vec3d
  get
-Converters().toLuaNullable(
+HitVec() %7B%0A      return 
 dele
@@ -1846,182 +1846,99 @@
 tVec
-))
 ;%0A    
-  addImmutable(%22pos%22, getConverters().toLuaNullable(new Vec3d(delegate.getBlockPos())));%0A      addImmutable(%22sideHit%22, getConverters().toLuaNullable(delegate.sideHit)
+%7D%0A%0A    @LuaProperty%0A    public BlockPos getPos() %7B%0A      return delegate.getBlockPos(
 );%0A 
@@ -1948,24 +1948,27 @@
 %7D%0A%0A    @
-Override
+LuaProperty
 %0A    pub
@@ -1975,30 +1975,29 @@
 lic 
-boolean isTransferable
+EnumFacing getSideHit
 () %7B
@@ -2014,12 +2014,24 @@
 urn 
-true
+delegate.sideHit
 ;%0A  

Update BlockHitClass to architecture 3