use of com.wuest.prefab.structures.items.StructureItem in project MC-Prefab by Brian-Wuest.
the class ClientEventHandler method KeyInput.
@SubscribeEvent(priority = EventPriority.NORMAL)
@OnlyIn(Dist.CLIENT)
public static void KeyInput(InputEvent.KeyInputEvent event) {
for (KeyMapping binding : ClientEventHandler.keyBindings) {
if (binding.isDown()) {
if (StructureRenderHandler.currentStructure != null) {
ItemStack mainHandStack = Minecraft.getInstance().player.getMainHandItem();
ItemStack offHandStack = Minecraft.getInstance().player.getOffhandItem();
boolean foundCorrectStructureItem = false;
if (mainHandStack != ItemStack.EMPTY || offHandStack != ItemStack.EMPTY) {
StructureTagMessage.EnumStructureConfiguration structureConfigurationEnum = StructureTagMessage.EnumStructureConfiguration.getByConfigurationInstance(StructureRenderHandler.currentConfiguration);
if (mainHandStack != ItemStack.EMPTY && mainHandStack.getItem() instanceof StructureItem) {
// Check main hand.
foundCorrectStructureItem = ClientEventHandler.checkIfStackIsCorrectGui(structureConfigurationEnum, mainHandStack);
}
if (!foundCorrectStructureItem && offHandStack != ItemStack.EMPTY && offHandStack.getItem() instanceof StructureItem) {
// Main hand is not correct item; check off-hand
foundCorrectStructureItem = ClientEventHandler.checkIfStackIsCorrectGui(structureConfigurationEnum, offHandStack);
}
}
if (foundCorrectStructureItem) {
Prefab.network.sendToServer(new StructureTagMessage(StructureRenderHandler.currentConfiguration.WriteToCompoundTag(), StructureTagMessage.EnumStructureConfiguration.getByConfigurationInstance(StructureRenderHandler.currentConfiguration)));
}
StructureRenderHandler.currentStructure = null;
}
break;
}
}
}
use of com.wuest.prefab.structures.items.StructureItem in project MC-Prefab by Brian-Wuest.
the class ClientProxy method openGuiForItem.
@Override
public void openGuiForItem(UseOnContext itemUseContext) {
for (Map.Entry<StructureItem, GuiStructure> entry : ClientProxy.ModGuis.entrySet()) {
if (entry.getKey() == itemUseContext.getItemInHand().getItem()) {
GuiStructure screen = entry.getValue();
screen.pos = itemUseContext.getClickedPos();
Minecraft.getInstance().setScreen(screen);
}
}
}
Aggregations