use of eu.pb4.armorstandeditor.mixin.ItemFrameEntityAccessor in project ArmorStandEditor by Patbox.
the class EditorGuis method openItemFrameEditor.
public static void openItemFrameEditor(ServerPlayerEntity player, ItemFrameEntity entity) {
ItemFrameEntityAccessor ifa = (ItemFrameEntityAccessor) entity;
SimpleGui gui = new SimpleGui(ScreenHandlerType.GENERIC_9X1, player, false);
ItemFrameInventory inventory = new ItemFrameInventory(entity);
GuiElement empty = new GuiElementBuilder(Items.GRAY_STAINED_GLASS_PANE).setName(new LiteralText("")).build();
gui.setTitle(new TranslatableText("armorstandeditor.gui.item_frame_title"));
gui.setSlotRedirect(0, new Slot(inventory, 0, 0, 0));
gui.setSlot(1, empty);
gui.setSlot(2, new GuiElementBuilder(ifa.getFixed() ? Items.GREEN_STAINED_GLASS_PANE : Items.RED_STAINED_GLASS_PANE).setName(new TranslatableText("armorstandeditor.gui.name.if-fixed", ifa.getFixed()).setStyle(Style.EMPTY.withItalic(false))).setCallback((index, type, action) -> {
ifa.setFixed(!ifa.getFixed());
ItemStack stack = new ItemStack(ifa.getFixed() ? Items.GREEN_STAINED_GLASS_PANE : Items.RED_STAINED_GLASS_PANE);
stack.setCustomName(new TranslatableText("armorstandeditor.gui.name.if-fixed", ifa.getFixed()).setStyle(Style.EMPTY.withItalic(false)));
((GuiElement) gui.getSlot(index)).setItemStack(stack);
}));
gui.setSlot(3, new GuiElementBuilder(entity.isInvisible() ? Items.GREEN_STAINED_GLASS_PANE : Items.RED_STAINED_GLASS_PANE).setName(new TranslatableText("armorstandeditor.gui.name.if-invisible", entity.isInvisible()).setStyle(Style.EMPTY.withItalic(false))).setCallback((index, type, action) -> {
entity.setInvisible(!entity.isInvisible());
System.out.println(entity.isInvisible());
ItemStack stack = new ItemStack(entity.isInvisible() ? Items.GREEN_STAINED_GLASS_PANE : Items.RED_STAINED_GLASS_PANE);
stack.setCustomName(new TranslatableText("armorstandeditor.gui.name.if-invisible", entity.isInvisible()).setStyle(Style.EMPTY.withItalic(false)));
((GuiElement) gui.getSlot(index)).setItemStack(stack);
}));
gui.setSlot(4, new GuiElementBuilder(Items.ARROW).setName(new TranslatableText("armorstandeditor.gui.name.if-rotate", entity.getRotation()).setStyle(Style.EMPTY.withItalic(false))).setCallback((index, type, action) -> {
if (type.isLeft || type.isRight) {
int rotation = entity.getRotation() + (type.isLeft ? -1 : 1);
if (rotation < 0) {
rotation = 8 + rotation;
}
entity.setRotation(rotation % 8);
ItemStack stack = new ItemStack(Items.ARROW);
stack.setCustomName(new TranslatableText("armorstandeditor.gui.name.if-rotate", rotation).setStyle(Style.EMPTY.withItalic(false)));
((GuiElement) gui.getSlot(index)).setItemStack(stack);
}
}));
for (int x = 5; x < 8; x++) {
gui.setSlot(x, empty);
}
gui.setSlot(8, new GuiElementBuilder(Items.BARRIER).setName(new TranslatableText("armorstandeditor.gui.close").setStyle(Style.EMPTY.withItalic(false))).setCallback(((index, type, action) -> {
gui.close();
})));
gui.open();
}
Aggregations