use of me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer in project BlockMeter by ModProg.
the class BlockMeterClient method onInitializeClient.
@Override
public void onInitializeClient() {
final KeyBinding keyBinding = new KeyBinding("key.blockmeter.assign", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_M, "category.blockmeter.key");
final KeyBinding keyBindingMenu = new KeyBinding("key.blockmeter.menu", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_LEFT_ALT, "category.blockmeter.key");
KeyBindingHelper.registerKeyBinding(keyBinding);
KeyBindingHelper.registerKeyBinding(keyBindingMenu);
// This is ugly I know, but I did not find something better
// (Issue in AutoConfig https://github.com/shedaniel/AutoConfig/issues/13)
confMgr = (ConfigManager<ModConfig>) AutoConfig.register(ModConfig.class, Toml4jConfigSerializer::new);
ClientTickEvents.START_CLIENT_TICK.register(e -> {
if (keyBinding.wasPressed()) {
if (Screen.hasShiftDown()) {
if (undo())
e.player.sendMessage(new TranslatableText("blockmeter.clearLast"), true);
} else if (Screen.hasControlDown()) {
if (clear())
e.player.sendMessage(new TranslatableText("blockmeter.clearAll"), true);
} else if (this.active) {
disable();
e.player.sendMessage(new TranslatableText("blockmeter.toggle.off", new Object[0]), true);
} else {
active = true;
ItemStack itemStack = e.player.getMainHandStack();
currentItem = itemStack.getItem();
e.player.sendMessage(new TranslatableText("blockmeter.toggle.on", new Object[] { new TranslatableText(itemStack.getTranslationKey(), new Object[0]) }), true);
}
}
if (keyBindingMenu.wasPressed() && active && MinecraftClient.getInstance().player.getMainHandStack().getItem() == this.currentItem) {
MinecraftClient.getInstance().setScreen((Screen) this.quickMenu);
}
// Updates Selection preview
if (this.active && this.boxes.size() > 0) {
final ClientMeasureBox currentBox = getCurrentBox();
if (currentBox != null) {
final HitResult rayHit = e.player.raycast((double) e.interactionManager.getReachDistance(), 1.0f, false);
if (rayHit.getType() == HitResult.Type.BLOCK) {
final BlockHitResult blockHitResult = (BlockHitResult) rayHit;
currentBox.setBlockEnd(new BlockPos(blockHitResult.getBlockPos()));
}
}
}
});
UseBlockCallback.EVENT.register((playerEntity, world, hand, hitResult) -> this.onBlockMeterClick(playerEntity, hitResult));
}
Aggregations