diff options
author | Jason Mitchell <mitchej@gmail.com> | 2023-01-28 19:03:53 -0800 |
---|---|---|
committer | Jason Mitchell <mitchej@gmail.com> | 2023-01-28 19:03:53 -0800 |
commit | f51616bda220887fdd45c4bc951ff59e3398213a (patch) | |
tree | 35fdbb15b4c7ea0282773a388eff517a1d09d941 /src/main/java/kubatech/loaders/item | |
parent | 11216d666cbc30fc1e1dfc84e1e0c2f4252b1fc2 (diff) | |
download | GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.tar.gz GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.tar.bz2 GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.zip |
[ci skip] spotlessApply with the new settings
Diffstat (limited to 'src/main/java/kubatech/loaders/item')
7 files changed, 233 insertions, 248 deletions
diff --git a/src/main/java/kubatech/loaders/item/IItemProxyGUI.java b/src/main/java/kubatech/loaders/item/IItemProxyGUI.java index 40020c81e9..6b16630ea1 100644 --- a/src/main/java/kubatech/loaders/item/IItemProxyGUI.java +++ b/src/main/java/kubatech/loaders/item/IItemProxyGUI.java @@ -1,9 +1,11 @@ package kubatech.loaders.item; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; + public interface IItemProxyGUI { + ModularWindow createWindow(ItemStack stack, EntityPlayer player); } diff --git a/src/main/java/kubatech/loaders/item/ItemProxy.java b/src/main/java/kubatech/loaders/item/ItemProxy.java index 0545932cf5..a0a841760c 100644 --- a/src/main/java/kubatech/loaders/item/ItemProxy.java +++ b/src/main/java/kubatech/loaders/item/ItemProxy.java @@ -1,33 +1,19 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.item; -import com.gtnewhorizons.modularui.api.screen.ModularUIContext; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.common.builder.UIBuilder; -import com.gtnewhorizons.modularui.common.builder.UIInfo; -import com.gtnewhorizons.modularui.common.internal.wrapper.ModularGui; -import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer; import java.util.List; + import kubatech.Tags; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -37,26 +23,33 @@ import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import com.gtnewhorizons.modularui.api.screen.ModularUIContext; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.builder.UIBuilder; +import com.gtnewhorizons.modularui.common.builder.UIInfo; +import com.gtnewhorizons.modularui.common.internal.wrapper.ModularGui; +import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer; + public class ItemProxy { - private static final UIInfo<?, ?> HeldItemUIInfo = UIBuilder.of() - .container((player, w, x, y, z) -> { - ItemStack stack = player.getHeldItem(); - ItemProxy proxy = KubaItems.getItemProxy(stack); - if (!(proxy instanceof IItemProxyGUI)) return null; - UIBuildContext context = new UIBuildContext(player); - ModularWindow window = ((IItemProxyGUI) proxy).createWindow(stack, player); - return new ModularUIContainer( - new ModularUIContext(context, () -> player.inventoryContainer.detectAndSendChanges()), window); - }) - .gui((player, w, x, y, z) -> { - ItemStack stack = player.getHeldItem(); - ItemProxy proxy = KubaItems.getItemProxy(stack); - if (!(proxy instanceof IItemProxyGUI)) return null; - UIBuildContext context = new UIBuildContext(player); - ModularWindow window = ((IItemProxyGUI) proxy).createWindow(stack, player); - return new ModularGui(new ModularUIContainer(new ModularUIContext(context, null), window)); - }) - .build(); + + private static final UIInfo<?, ?> HeldItemUIInfo = UIBuilder.of().container((player, w, x, y, z) -> { + ItemStack stack = player.getHeldItem(); + ItemProxy proxy = KubaItems.getItemProxy(stack); + if (!(proxy instanceof IItemProxyGUI)) return null; + UIBuildContext context = new UIBuildContext(player); + ModularWindow window = ((IItemProxyGUI) proxy).createWindow(stack, player); + return new ModularUIContainer( + new ModularUIContext(context, () -> player.inventoryContainer.detectAndSendChanges()), + window); + }).gui((player, w, x, y, z) -> { + ItemStack stack = player.getHeldItem(); + ItemProxy proxy = KubaItems.getItemProxy(stack); + if (!(proxy instanceof IItemProxyGUI)) return null; + UIBuildContext context = new UIBuildContext(player); + ModularWindow window = ((IItemProxyGUI) proxy).createWindow(stack, player); + return new ModularGui(new ModularUIContainer(new ModularUIContext(context, null), window)); + }).build(); private final String unlocalizedName; private final String texturepath; private IIcon icon; diff --git a/src/main/java/kubatech/loaders/item/KubaItems.java b/src/main/java/kubatech/loaders/item/KubaItems.java index cb738d77fa..55d835cb87 100644 --- a/src/main/java/kubatech/loaders/item/KubaItems.java +++ b/src/main/java/kubatech/loaders/item/KubaItems.java @@ -1,31 +1,22 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.item; import static kubatech.kubatech.KT; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.HashMap; import java.util.List; + import kubatech.loaders.ItemLoader; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -36,7 +27,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class KubaItems extends Item { + private static final HashMap<Integer, ItemProxy> items = new HashMap<>(); private static int idCounter = 0; @@ -67,17 +62,8 @@ public class KubaItems extends Item { } @Override - public boolean onItemUse( - ItemStack p_77648_1_, - EntityPlayer p_77648_2_, - World p_77648_3_, - int p_77648_4_, - int p_77648_5_, - int p_77648_6_, - int p_77648_7_, - float p_77648_8_, - float p_77648_9_, - float p_77648_10_) { + public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, + int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { return false; } @@ -141,8 +127,8 @@ public class KubaItems extends Item { } @Override - public void onUpdate( - ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { + public void onUpdate(ItemStack p_77663_1_, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, + boolean p_77663_5_) { getItem(p_77663_1_).onUpdate(p_77663_1_, p_77663_2_, p_77663_3_, p_77663_4_, p_77663_5_); } } diff --git a/src/main/java/kubatech/loaders/item/items/Tea.java b/src/main/java/kubatech/loaders/item/items/Tea.java index a810967ed2..c127609cf9 100644 --- a/src/main/java/kubatech/loaders/item/items/Tea.java +++ b/src/main/java/kubatech/loaders/item/items/Tea.java @@ -1,32 +1,26 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.item.items; import java.util.List; + import kubatech.loaders.item.ItemProxy; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class Tea extends ItemProxy { + private final int heal; private final float saturation; diff --git a/src/main/java/kubatech/loaders/item/items/TeaCollection.java b/src/main/java/kubatech/loaders/item/items/TeaCollection.java index 8440576fe2..5ef3995301 100644 --- a/src/main/java/kubatech/loaders/item/items/TeaCollection.java +++ b/src/main/java/kubatech/loaders/item/items/TeaCollection.java @@ -1,29 +1,22 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.item.items; import java.util.LinkedList; import java.util.List; + import kubatech.api.utils.ModUtils; import kubatech.loaders.ItemLoader; import kubatech.loaders.item.ItemProxy; + import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.Entity; @@ -41,6 +34,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.AchievementPage; public class TeaCollection extends ItemProxy { + protected static TeaPage teapage; protected static LinkedList<Achievement> achievements; protected Achievement achievement; @@ -51,21 +45,8 @@ public class TeaCollection extends ItemProxy { achievementname = "teacollection." + unlocalizedName; } - private static final int[][] achievement_poses = new int[][] { - {0, 0}, - {2, 0}, - {3, 1}, - {4, 2}, - {4, 4}, - {3, 5}, - {2, 6}, - {0, 6}, - {-1, 5}, - {-2, 4}, - {-2, 2}, - {-1, 1}, - {1, 3} - }; + private static final int[][] achievement_poses = new int[][] { { 0, 0 }, { 2, 0 }, { 3, 1 }, { 4, 2 }, { 4, 4 }, + { 3, 5 }, { 2, 6 }, { 0, 6 }, { -1, 5 }, { -2, 4 }, { -2, 2 }, { -1, 1 }, { 1, 3 } }; boolean checkTeaOwner(ItemStack stack, String username) { NBTTagCompound tag = stack.stackTagCompound; @@ -92,25 +73,34 @@ public class TeaCollection extends ItemProxy { } achievements.add( achievement = new Achievement( - achievementname, - achievementname, - achievement_poses[index][0], - achievement_poses[index][1], - new ItemStack(ItemLoader.kubaitems, 1, index), - null) - .registerStat()); + achievementname, + achievementname, + achievement_poses[index][0], + achievement_poses[index][1], + new ItemStack(ItemLoader.kubaitems, 1, index), + null).registerStat()); } @Override public void addInformation(ItemStack stack, EntityPlayer entity, List<String> tooltipList, boolean showDebugInfo) { if (!checkTeaOwner(stack, entity.getCommandSenderName())) { - tooltipList.add(EnumChatFormatting.GRAY + "" + EnumChatFormatting.BOLD + "" + EnumChatFormatting.ITALIC - + StatCollector.translateToLocal("kubaitem.notyours")); + tooltipList.add( + EnumChatFormatting.GRAY + "" + + EnumChatFormatting.BOLD + + "" + + EnumChatFormatting.ITALIC + + StatCollector.translateToLocal("kubaitem.notyours")); return; } tooltipList.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("kubaitem.fromcollection")); - tooltipList.add(EnumChatFormatting.GRAY + "" + EnumChatFormatting.BOLD + "" + EnumChatFormatting.ITALIC + "" - + EnumChatFormatting.UNDERLINE + StatCollector.translateToLocal("kubaitem.teacollection")); + tooltipList.add( + EnumChatFormatting.GRAY + "" + + EnumChatFormatting.BOLD + + "" + + EnumChatFormatting.ITALIC + + "" + + EnumChatFormatting.UNDERLINE + + StatCollector.translateToLocal("kubaitem.teacollection")); } @Override @@ -129,8 +119,9 @@ public class TeaCollection extends ItemProxy { public ItemStack onEaten(ItemStack stack, World world, EntityPlayer entity) { if (world.isRemote) return stack; if (!(entity instanceof EntityPlayerMP)) return stack; - entity.addChatComponentMessage(new ChatComponentText( - EnumChatFormatting.GREEN + StatCollector.translateToLocal("kubaitem.teacollection.mmm"))); + entity.addChatComponentMessage( + new ChatComponentText( + EnumChatFormatting.GREEN + StatCollector.translateToLocal("kubaitem.teacollection.mmm"))); entity.triggerAchievement(achievement); return stack; } diff --git a/src/main/java/kubatech/loaders/item/items/TeaIngredient.java b/src/main/java/kubatech/loaders/item/items/TeaIngredient.java index 135129742a..696f004316 100644 --- a/src/main/java/kubatech/loaders/item/items/TeaIngredient.java +++ b/src/main/java/kubatech/loaders/item/items/TeaIngredient.java @@ -1,31 +1,25 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.item.items; import java.util.List; + import kubatech.loaders.item.ItemProxy; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; public class TeaIngredient extends ItemProxy { + public TeaIngredient(String unlocalizedName) { super("teaingredient." + unlocalizedName, "teaingredient/" + unlocalizedName); } diff --git a/src/main/java/kubatech/loaders/item/items/TeaUltimate.java b/src/main/java/kubatech/loaders/item/items/TeaUltimate.java index 6356d30fbb..35b4ae28f1 100644 --- a/src/main/java/kubatech/loaders/item/items/TeaUltimate.java +++ b/src/main/java/kubatech/loaders/item/items/TeaUltimate.java @@ -1,39 +1,24 @@ /* - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. - * + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * <https://www.gnu.org/licenses/>. */ package kubatech.loaders.item.items; -import com.gtnewhorizons.modularui.api.ModularUITextures; -import com.gtnewhorizons.modularui.api.drawable.IDrawable; -import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; -import com.gtnewhorizons.modularui.api.drawable.Text; -import com.gtnewhorizons.modularui.api.math.Color; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.widget.Widget; -import com.gtnewhorizons.modularui.common.widget.*; import java.text.NumberFormat; + import kubatech.api.enums.ItemList; import kubatech.api.utils.ModUtils; import kubatech.api.utils.StringUtils; import kubatech.loaders.item.IItemProxyGUI; import kubatech.savedata.PlayerData; import kubatech.savedata.PlayerDataManager; + import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -46,7 +31,17 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.*; + public class TeaUltimate extends TeaCollection implements IItemProxyGUI { + public TeaUltimate() { super("ultimate_tea"); } @@ -60,7 +55,9 @@ public class TeaUltimate extends TeaCollection implements IItemProxyGUI { if (current - timeCounter > 100) { timeCounter = current; name = StringUtils.applyRainbow( - "ULTIMATE", colorCounter++, EnumChatFormatting.BOLD.toString() + EnumChatFormatting.OBFUSCATED); + "ULTIMATE", + colorCounter++, + EnumChatFormatting.BOLD.toString() + EnumChatFormatting.OBFUSCATED); } return String.format(displayName, name + EnumChatFormatting.RESET); } @@ -82,79 +79,107 @@ public class TeaUltimate extends TeaCollection implements IItemProxyGUI { IDrawable tab1 = new ItemDrawable(ItemList.LegendaryUltimateTea.get(1)).withFixedSize(18, 18, 4, 6); IDrawable tab2 = new ItemDrawable(new ItemStack(Blocks.crafting_table)).withFixedSize(18, 18, 4, 6); IDrawable tab3 = new ItemDrawable(new ItemStack(Items.golden_apple)).withFixedSize(18, 18, 4, 6); - builder.widget(new TabContainer() - .setButtonSize(28, 32) - .addTabButton(new TabButton(0) - .setBackground(false, ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0, 1f, 0.5f), tab1) - .setBackground(true, ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0.5f, 1f, 1f), tab1) - .setPos(0, -28)) - .addTabButton(new TabButton(1) - .setBackground(false, ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), tab2) - .setBackground(true, ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), tab2) - .setPos(28, -28)) - .addTabButton(new TabButton(2) - .setBackground(false, ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), tab3) - .setBackground(true, ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), tab3) - .setPos(56, -28)) - .addPage(new MultiChildWidget() - .addChild(new TextWidget(new Text("STATUS") - .format(EnumChatFormatting.BOLD) - .format(EnumChatFormatting.GOLD) - .shadow()) - .setPos(10, 5)) - .addChild(new DynamicTextWidget(() -> new Text("Tea: " - + (playerData == null - ? "ERROR" - : NumberFormat.getInstance() - .format(playerData.teaAmount))) - .color(Color.GREEN.normal)) - .setPos(20, 20))) - .addPage(new MultiChildWidget() - .addChild(new TextWidget(new Text("EXCHANGE") - .format(EnumChatFormatting.BOLD) - .format(EnumChatFormatting.GOLD) - .shadow()) - .setPos(10, 5)) - .addChild(new ButtonWidget() - .setOnClick((Widget.ClickData clickData, Widget widget) -> { - if (!(player instanceof EntityPlayerMP)) return; - if (playerData == null || playerData.teaAmount < 50_000L) return; - playerData.teaAmount -= 50_000L; - playerData.markDirty(); - if (player.inventory.addItemStackToInventory( - ItemList.TeaAcceptorResearchNote.get(1))) return; - player.entityDropItem(ItemList.TeaAcceptorResearchNote.get(1), 0.5f); - }) - .setBackground(new ItemDrawable().setItem(ItemList.TeaAcceptorResearchNote.get(1))) - .addTooltip("Tea Acceptor Research Note") - .addTooltip(new Text("Cost: " - + NumberFormat.getInstance().format(50_000) + " Tea") - .color(Color.GRAY.normal)) - .setPos(20, 20))) - .addPage( - new MultiChildWidget() - .addChild(new TextWidget(new Text("BENEFITS") - .format(EnumChatFormatting.BOLD) - .format(EnumChatFormatting.GOLD) - .shadow()) - .setPos(10, 5)) - /*.addChild(new ButtonWidget() - .setOnClick((Widget.ClickData clickData, Widget widget) -> { - if (!(player instanceof EntityPlayerMP)) return; - if (playerData == null) return; - playerData.autoRegen = !playerData.autoRegen; - playerData.markDirty(); - }) - .setBackground(new ItemDrawable().setItem(new ItemStack(Items.potionitem, 1, 8193))) - .addTooltip("Regeneration I") - .addTooltip("For 1 minute") - .addTooltip(new Text("Cost: " - + NumberFormat.getInstance().format(75_000) + " Tea") - .color(Color.GRAY.normal)) - // .addTooltip( //Find a way to run that on server, or different approach - // new Text("Autobuy: " + (playerData == null ? "ERROR" : playerData.autoRegen)) - // .color(Color.GREY.normal)) - .setPos(20, 20))*/ )); + builder.widget( + new TabContainer() + .setButtonSize( + 28, + 32) + .addTabButton( + new TabButton(0) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0, 1f, 0.5f), + tab1) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0.5f, 1f, 1f), + tab1) + .setPos(0, -28)) + .addTabButton( + new TabButton(1) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + tab2) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + tab2) + .setPos(28, -28)) + .addTabButton( + new TabButton(2) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + tab3) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + tab3) + .setPos(56, -28)) + .addPage( + new MultiChildWidget() + .addChild( + new TextWidget( + new Text("STATUS").format(EnumChatFormatting.BOLD) + .format(EnumChatFormatting.GOLD).shadow()) + .setPos(10, 5)) + .addChild( + new DynamicTextWidget( + () -> new Text( + "Tea: " + (playerData == null ? "ERROR" + : NumberFormat.getInstance() + .format(playerData.teaAmount))) + .color(Color.GREEN.normal)) + .setPos(20, 20))) + .addPage( + new MultiChildWidget() + .addChild( + new TextWidget( + new Text("EXCHANGE").format(EnumChatFormatting.BOLD) + .format(EnumChatFormatting.GOLD).shadow()) + .setPos(10, 5)) + .addChild( + new ButtonWidget() + .setOnClick((Widget.ClickData clickData, Widget widget) -> { + if (!(player instanceof EntityPlayerMP)) return; + if (playerData == null || playerData.teaAmount < 50_000L) + return; + playerData.teaAmount -= 50_000L; + playerData.markDirty(); + if (player.inventory.addItemStackToInventory( + ItemList.TeaAcceptorResearchNote.get(1))) + return; + player.entityDropItem( + ItemList.TeaAcceptorResearchNote.get(1), + 0.5f); + }) + .setBackground( + new ItemDrawable().setItem( + ItemList.TeaAcceptorResearchNote.get(1))) + .addTooltip("Tea Acceptor Research Note") + .addTooltip( + new Text( + "Cost: " + NumberFormat.getInstance() + .format(50_000) + " Tea") + .color(Color.GRAY.normal)) + .setPos(20, 20))) + .addPage( + new MultiChildWidget().addChild( + new TextWidget( + new Text("BENEFITS").format(EnumChatFormatting.BOLD) + .format(EnumChatFormatting.GOLD).shadow()).setPos(10, 5)) + /* + * .addChild(new ButtonWidget() .setOnClick((Widget.ClickData clickData, Widget widget) -> { if + * (!(player instanceof EntityPlayerMP)) return; if (playerData == null) return; + * playerData.autoRegen = !playerData.autoRegen; playerData.markDirty(); }) .setBackground(new + * ItemDrawable().setItem(new ItemStack(Items.potionitem, 1, 8193))) + * .addTooltip("Regeneration I") .addTooltip("For 1 minute") .addTooltip(new Text("Cost: " + + * NumberFormat.getInstance().format(75_000) + " Tea") .color(Color.GRAY.normal)) // + * .addTooltip( //Find a way to run that on server, or different approach // new + * Text("Autobuy: " + (playerData == null ? "ERROR" : playerData.autoRegen)) // + * .color(Color.GREY.normal)) .setPos(20, 20)) + */ )); return builder.build(); } |