generated from CleanroomMC/ForgeDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathHoloGuiFactory.java
More file actions
43 lines (32 loc) · 1.34 KB
/
HoloGuiFactory.java
File metadata and controls
43 lines (32 loc) · 1.34 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 com.cleanroommc.modularui.factory;
import com.cleanroommc.modularui.api.IGuiHolder;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.EnumHand;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public class HoloGuiFactory extends AbstractUIFactory<HandGuiData>{
public static final HoloGuiFactory INSTANCE = new HoloGuiFactory();
protected HoloGuiFactory() {
super("mui:holo");
}
public static void open(EntityPlayerMP player, EnumHand hand) {
Objects.requireNonNull(player);
Objects.requireNonNull(hand);
HandGuiData guiData = new HandGuiData(player, hand);
HoloGuiManager.open(INSTANCE, guiData, player);
}
@Override
public @NotNull IGuiHolder<HandGuiData> getGuiHolder(HandGuiData data) {
return Objects.requireNonNull(castGuiHolder(data.getUsedItemStack().getItem()), "Item was not a gui holder!");
}
@Override
public void writeGuiData(HandGuiData guiData, PacketBuffer buffer) {
buffer.writeByte(guiData.getHand().ordinal());
}
@Override
public @NotNull HandGuiData readGuiData(EntityPlayer player, PacketBuffer buffer) {
return new HandGuiData(player, EnumHand.values()[buffer.readByte()]);
}
}