This repository was archived by the owner on Jun 1, 2021. It is now read-only.
forked from MightyPirates/OpenComputers
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCase.kt
More file actions
43 lines (36 loc) · 1.39 KB
/
Copy pathCase.kt
File metadata and controls
43 lines (36 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package li.cli.oc.blockentity
import li.cli.oc.blocks.commons.RedstoneAwareEntity
import li.cli.oc.client.gui.blocks.CaseScreenHandler
import li.cli.oc.components.BlockEntitiesComponent
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory
import net.minecraft.block.BlockState
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.entity.player.PlayerInventory
import net.minecraft.nbt.CompoundTag
import net.minecraft.network.PacketByteBuf
import net.minecraft.screen.ScreenHandler
import net.minecraft.server.network.ServerPlayerEntity
import net.minecraft.text.Text
class CaseEntity(var Tier: Int) : RedstoneAwareEntity(BlockEntitiesComponent.Case), ExtendedScreenHandlerFactory {
init {
markDirty()
}
override fun createMenu(syncId: Int, inv: PlayerInventory, player: PlayerEntity): ScreenHandler {
return CaseScreenHandler(syncId, inv, Tier)
}
override fun getDisplayName(): Text {
return Text.of("Computer")
}
override fun writeScreenOpeningData(playerEntity: ServerPlayerEntity?, buf: PacketByteBuf?) {
buf?.writeInt(Tier)
}
override fun toTag(tag: CompoundTag): CompoundTag {
super.toTag(tag)
tag.putInt("tier", Tier)
return tag
}
override fun fromTag(state: BlockState?, tag: CompoundTag?) {
super.fromTag(state, tag)
Tier = tag?.getInt("tier")!!
}
}