-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactoring, new visualization using display entities, more ref…
…actoring
- Loading branch information
Showing
26 changed files
with
800 additions
and
292 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
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
87 changes: 69 additions & 18 deletions
87
api/src/main/java/dev/cerus/visualcrafting/api/version/FakeItemDisplay.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 |
---|---|---|
@@ -1,62 +1,113 @@ | ||
package dev.cerus.visualcrafting.api.version; | ||
|
||
import dev.cerus.visualcrafting.api.math.MatrixMath; | ||
import org.bukkit.Location; | ||
import org.bukkit.block.BlockFace; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.joml.Matrix3f; | ||
import org.joml.Matrix4f; | ||
|
||
/** | ||
* A fake item display | ||
*/ | ||
public class FakeItemDisplay { | ||
|
||
private final Location location; | ||
private final ItemStack itemStack; | ||
private final BlockFace rotationX; | ||
private final BlockFace rotationY; | ||
private final Transform transform; | ||
private static final float SCALE = 0.18f; | ||
|
||
private ItemStack itemStack; | ||
private Matrix3f rotationX; | ||
private Matrix3f rotationZ; | ||
private Matrix4f translation; | ||
private Transform transform; | ||
private Location location; | ||
|
||
public FakeItemDisplay(final Location location, | ||
final ItemStack itemStack, | ||
final BlockFace rotationX, | ||
final BlockFace rotationY, | ||
final Matrix3f rotationX, | ||
final Matrix3f rotationZ, | ||
final Matrix4f translation, | ||
final Transform transform) { | ||
this.location = location; | ||
this.itemStack = itemStack; | ||
this.rotationX = rotationX; | ||
this.rotationY = rotationY; | ||
this.rotationZ = rotationZ; | ||
this.translation = translation; | ||
this.transform = transform; | ||
} | ||
|
||
/** | ||
* Create the transformation matrix for displaying an item | ||
* | ||
* @return the matrix | ||
*/ | ||
public Matrix4f getTransformationMatrix() { | ||
return MatrixMath.combine( | ||
this.translation, | ||
MatrixMath.combineAndExpand( | ||
this.rotationX, | ||
this.rotationZ | ||
), | ||
MatrixMath.scale(SCALE, SCALE, 0.0001f) | ||
); | ||
} | ||
|
||
public Location getLocation() { | ||
return this.location; | ||
} | ||
|
||
public void setLocation(final Location location) { | ||
this.location = location; | ||
} | ||
|
||
public ItemStack getItemStack() { | ||
return this.itemStack; | ||
} | ||
|
||
public BlockFace getRotationX() { | ||
public void setItemStack(final ItemStack itemStack) { | ||
this.itemStack = itemStack; | ||
} | ||
|
||
public Matrix3f getRotationX() { | ||
return this.rotationX; | ||
} | ||
|
||
public BlockFace getRotationY() { | ||
return this.rotationY; | ||
public void setRotationX(final Matrix3f rotationX) { | ||
this.rotationX = rotationX; | ||
} | ||
|
||
public Matrix3f getRotationZ() { | ||
return this.rotationZ; | ||
} | ||
|
||
public void setRotationZ(final Matrix3f rotationZ) { | ||
this.rotationZ = rotationZ; | ||
} | ||
|
||
public Matrix4f getTranslation() { | ||
return this.translation; | ||
} | ||
|
||
public void setTranslation(final Matrix4f translation) { | ||
this.translation = translation; | ||
} | ||
|
||
public Transform getTransform() { | ||
return this.transform; | ||
} | ||
|
||
public void setTransform(final Transform transform) { | ||
this.transform = transform; | ||
} | ||
|
||
public enum Transform { | ||
NONE, | ||
THIRDPERSON_LEFTHAND, | ||
THIRDPERSON_RIGHTHAND, | ||
FIRSTPERSON_LEFTHAND, | ||
FIRSTPERSON_RIGHTHAND, | ||
FIXED, | ||
GROUND, | ||
GUI, | ||
HEAD, | ||
NONE, | ||
THIRDPERSON_LEFTHAND, | ||
THIRDPERSON_RIGHTHAND | ||
GUI, | ||
GROUND, | ||
FIXED | ||
} | ||
|
||
} |
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
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
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
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
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
Oops, something went wrong.