-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Quad, BlockPos, and QuadProvider API
Also optimize static models
- Loading branch information
Showing
49 changed files
with
701 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/com/gtnewhorizons/angelica/api/BlockPos.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.gtnewhorizons.angelica.api; | ||
|
||
import com.gtnewhorizons.angelica.compat.mojang.BlockPosImpl; | ||
import net.minecraft.util.MathHelper; | ||
import net.minecraftforge.common.util.ForgeDirection; | ||
|
||
import java.math.RoundingMode; | ||
|
||
import static com.google.common.math.IntMath.log2; | ||
|
||
public interface BlockPos { | ||
|
||
int SIZE_BITS_X = 1 + log2(MathHelper.roundUpToPowerOfTwo(30000000), RoundingMode.UNNECESSARY); | ||
int SIZE_BITS_Z = SIZE_BITS_X; | ||
int SIZE_BITS_Y = 64 - SIZE_BITS_X - SIZE_BITS_Z; | ||
long BITS_X = (1L << SIZE_BITS_X) - 1L; | ||
long BITS_Y = (1L << SIZE_BITS_Y) - 1L; | ||
long BITS_Z = (1L << SIZE_BITS_Z) - 1L; | ||
int BIT_SHIFT_Z = SIZE_BITS_Y; | ||
int BIT_SHIFT_X = SIZE_BITS_Y + SIZE_BITS_Z; | ||
|
||
int getX(); | ||
int getY(); | ||
int getZ(); | ||
BlockPosImpl offset(ForgeDirection d); | ||
BlockPosImpl down(); | ||
BlockPosImpl up(); | ||
long asLong(); | ||
|
||
static long asLong(int x, int y, int z) { | ||
long l = 0L; | ||
l |= ((long) x & BITS_X) << BIT_SHIFT_X; | ||
l |= ((long) y & BITS_Y) << 0; | ||
l |= ((long) z & BITS_Z) << BIT_SHIFT_Z; | ||
return l; | ||
} | ||
|
||
public static int unpackLongX(long packedPos) { | ||
return (int)(packedPos << 64 - BIT_SHIFT_X - SIZE_BITS_X >> 64 - SIZE_BITS_X); | ||
} | ||
|
||
public static int unpackLongY(long packedPos) { | ||
return (int)(packedPos << 64 - SIZE_BITS_Y >> 64 - SIZE_BITS_Y); | ||
} | ||
|
||
public static int unpackLongZ(long packedPos) { | ||
return (int)(packedPos << 64 - BIT_SHIFT_Z - SIZE_BITS_Z >> 64 - SIZE_BITS_Z); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/gtnewhorizons/angelica/api/MutableBlockPos.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.gtnewhorizons.angelica.api; | ||
|
||
public interface MutableBlockPos extends BlockPos { | ||
|
||
MutableBlockPos set(int x, int y, int z); | ||
|
||
MutableBlockPos set(long packedPos); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/gtnewhorizons/angelica/api/QuadView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.gtnewhorizons.angelica.api; | ||
|
||
import me.jellysquid.mods.sodium.client.model.quad.ModelQuadViewMutable; | ||
import me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer; | ||
import net.minecraftforge.common.util.ForgeDirection; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public interface QuadView extends ModelQuadViewMutable { | ||
|
||
boolean isShade(); | ||
boolean isDeleted(); | ||
ForgeDirection getFace(); | ||
void copyFrom(QuadView src); | ||
void setRaw(int[] data, boolean shade, @Nullable ForgeDirection face, int colorIndex, int flags); | ||
int[] getRawVertexes(); | ||
|
||
/** | ||
* Present for compatibility with the Tesselator, not recommended for general use. | ||
*/ | ||
void setState(int[] rawBuffer, int offset, BlockRenderer.Flags flags, int drawMode, float offsetX, float offsetY, float offsetZ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 0 additions & 102 deletions
102
src/main/java/com/gtnewhorizons/angelica/compat/mojang/BlockPos.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.