Exemplo n.º 1
0
 private void putVertex(
     UnpackedBakedQuad.Builder builder,
     EnumFacing side,
     float x,
     float y,
     float z,
     float u,
     float v) {
   for (int e = 0; e < format.getElementCount(); e++) {
     switch (format.getElement(e).getUsage()) {
       case POSITION:
         float[] data =
             new float[] {
               x - side.getDirectionVec().getX() * eps,
               y,
               z - side.getDirectionVec().getZ() * eps,
               1
             };
         if (transformation.isPresent()
             && transformation.get() != TRSRTransformation.identity()) {
           Vector4f vec = new Vector4f(data);
           transformation.get().getMatrix().transform(vec);
           vec.get(data);
         }
         builder.put(e, data);
         break;
       case COLOR:
         builder.put(
             e,
             ((color >> 16) & 0xFF) / 255f,
             ((color >> 8) & 0xFF) / 255f,
             (color & 0xFF) / 255f,
             ((color >> 24) & 0xFF) / 255f);
         break;
       case UV:
         if (format.getElement(e).getIndex() == 0) {
           builder.put(e, u, v, 0f, 1f);
           break;
         }
       case NORMAL:
         builder.put(
             e,
             (float) side.getFrontOffsetX(),
             (float) side.getFrontOffsetY(),
             (float) side.getFrontOffsetZ(),
             0f);
         break;
       default:
         builder.put(e);
         break;
     }
   }
 }
 ClayLump extrudeLump(ClayLump against, EnumFacing dir) {
   ClayLump lump = against.copy();
   Block b = FzUtil.getTraceHelper();
   against.toBlockBounds(b);
   int wX = lump.maxX - lump.minX;
   int wY = lump.maxY - lump.minY;
   int wZ = lump.maxZ - lump.minZ;
   lump.maxX += wX * dir.getDirectionVec().getX();
   lump.maxY += wY * dir.getDirectionVec().getY();
   lump.maxZ += wZ * dir.getDirectionVec().getZ();
   lump.minX += wX * dir.getDirectionVec().getX();
   lump.minY += wY * dir.getDirectionVec().getY();
   lump.minZ += wZ * dir.getDirectionVec().getZ();
   return lump;
 }
 @Override
 public void onPlacedBy(
     EntityPlayer player, ItemStack is, EnumFacing side, float hitX, float hitY, float hitZ) {
   super.onPlacedBy(player, is, side, hitX, hitY, hitZ);
   NBTTagCompound tag = null;
   if (is.hasTagCompound()) {
     tag = is.getTagCompound();
     try {
       putData(new DataInNBT(tag));
     } catch (IOException e) {
       e.printStackTrace();
     }
   } else {
     addLump();
   }
   EnumFacing placement = SpaceUtil.determineFlatOrientation(player);
   if (tag == null || !tag.hasKey("front")) {
     front = placement;
     setRotation((byte) 0);
   } else if (placement.getDirectionVec().getY() == 0 && placement != null) {
     front = SpaceUtil.getOrientation(tag.getByte("front"));
     if (front == null || front.getDirectionVec().getY() != 0) {
       setRotation((byte) 0);
       front = placement;
     } else {
       EnumFacing f = placement;
       byte r = 0;
       for (byte i = 0; i < 4; i++) {
         if (f == front) {
           r = i;
           break;
         }
         f = SpaceUtil.rotate(f, EnumFacing.UP);
       }
       setRotation(r);
     }
   }
 }
Exemplo n.º 4
0
 public Vector(EnumFacing facing) {
   this(facing.getDirectionVec());
 }