-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef76a53
commit d5b2a82
Showing
14 changed files
with
163 additions
and
174 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
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
125 changes: 0 additions & 125 deletions
125
src/main/java/miyucomics/hexical/entities/MeshEntity.kt
This file was deleted.
Oops, something went wrong.
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
73 changes: 73 additions & 0 deletions
73
src/main/java/miyucomics/hexical/entities/specklikes/MeshEntity.kt
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,73 @@ | ||
package miyucomics.hexical.entities.specklikes | ||
|
||
import at.petrak.hexcasting.api.spell.iota.Vec3Iota | ||
import at.petrak.hexcasting.api.utils.putCompound | ||
import at.petrak.hexcasting.api.utils.putList | ||
import miyucomics.hexical.inits.HexicalEntities | ||
import net.minecraft.entity.EntityType | ||
import net.minecraft.entity.data.DataTracker | ||
import net.minecraft.entity.data.TrackedData | ||
import net.minecraft.entity.data.TrackedDataHandlerRegistry | ||
import net.minecraft.nbt.NbtCompound | ||
import net.minecraft.nbt.NbtElement | ||
import net.minecraft.nbt.NbtFloat | ||
import net.minecraft.nbt.NbtList | ||
import net.minecraft.util.math.Vec3d | ||
import net.minecraft.util.math.Vec3f | ||
import net.minecraft.world.World | ||
|
||
@OptIn(ExperimentalStdlibApi::class) | ||
open class MeshEntity(entityType: EntityType<MeshEntity>, world: World) : BaseSpecklike(entityType, world) { | ||
constructor(world: World) : this(HexicalEntities.MESH_ENTITY, world) | ||
|
||
var clientVertices: MutableList<Vec3f> = mutableListOf() | ||
|
||
fun getShape(): List<Vec3Iota> { | ||
val list = dataTracker.get(shapeDataTracker).getList("shape", NbtElement.FLOAT_TYPE.toInt()) | ||
val deserializedVertices = mutableListOf<Vec3Iota>() | ||
for (i in 0..<(list.size / 3)) | ||
deserializedVertices.add(Vec3Iota(Vec3d(list.getFloat(3 * i).toDouble(), list.getFloat(3 * i + 1).toDouble(), list.getFloat(3 * i + 2).toDouble()))) | ||
return deserializedVertices | ||
} | ||
|
||
fun setShape(shape: List<Vec3f>) { | ||
val compound = NbtCompound() | ||
val list = NbtList() | ||
for (vertex in shape) { | ||
list.add(NbtFloat.of(vertex.x)) | ||
list.add(NbtFloat.of(vertex.y)) | ||
list.add(NbtFloat.of(vertex.z)) | ||
} | ||
compound.putList("shape", list) | ||
this.dataTracker.set(shapeDataTracker, compound) | ||
} | ||
|
||
override fun readCustomDataFromNbt(nbt: NbtCompound) { | ||
super.readCustomDataFromNbt(nbt) | ||
dataTracker.set(shapeDataTracker, nbt.getCompound("shape")) | ||
} | ||
|
||
override fun writeCustomDataToNbt(nbt: NbtCompound) { | ||
super.writeCustomDataToNbt(nbt) | ||
nbt.putCompound("shape", dataTracker.get(shapeDataTracker)) | ||
} | ||
|
||
override fun initDataTracker() { | ||
super.initDataTracker() | ||
dataTracker.startTracking(shapeDataTracker, NbtCompound()) | ||
} | ||
|
||
override fun onTrackedDataSet(data: TrackedData<*>) { | ||
super.onTrackedDataSet(data) | ||
if (data == shapeDataTracker) { | ||
val list = this.dataTracker.get(shapeDataTracker).getList("shape", NbtElement.FLOAT_TYPE.toInt()) | ||
this.clientVertices = mutableListOf() | ||
for (i in 0..<(list.size / 3)) | ||
clientVertices.add(Vec3f(list.getFloat(3 * i), list.getFloat(3 * i + 1), list.getFloat(3 * i + 2))) | ||
} | ||
} | ||
|
||
companion object { | ||
private val shapeDataTracker: TrackedData<NbtCompound> = DataTracker.registerData(MeshEntity::class.java, TrackedDataHandlerRegistry.NBT_COMPOUND) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...yucomics/hexical/entities/MeshRenderer.kt → ...xical/entities/specklikes/MeshRenderer.kt
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.