aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kubatech/loaders/item/items/TeaUltimate.java
diff options
context:
space:
mode:
authorJakub <53441451+kuba6000@users.noreply.github.com>2022-12-15 16:53:12 +0100
committerGitHub <noreply@github.com>2022-12-15 16:53:12 +0100
commit8a581938862a4d612f510a8afed88727a34c3916 (patch)
tree0307ca87f3c06bbeda6d699aabbc2247b6f38efb /src/main/java/kubatech/loaders/item/items/TeaUltimate.java
parent24a9953b153529191c855af0ae2d10f35844095f (diff)
downloadGT5-Unofficial-8a581938862a4d612f510a8afed88727a34c3916.tar.gz
GT5-Unofficial-8a581938862a4d612f510a8afed88727a34c3916.tar.bz2
GT5-Unofficial-8a581938862a4d612f510a8afed88727a34c3916.zip
MODULAR UI (#34)
* MODULAR UUUUUUUUIIIIIIIIIII * Tea * Add recipe to ULTIMATE TEA * Stupid MT Scripts. I hate it * Yeet * More TEA * Add blocks * More Modular UIs * Textures * Fix custom UI containers * Texture, tooltip * UI with tabs * ButtonWidget * fix * Fix * Texture * Color is fixed * More UI work * Modular UI is hard dependency now * Spotless * Simplify * Format numbers * A * Update TeaAcceptorTile.java * Shadow is fixed, lets gooooo * hardness * Mixins mixins mixins * Tab icons * Fix crash * Shop concept * Bump ModularUI * Bump Modular UI * Nooooooooooo * GREY -> GRAY * Bump ModularUI * Bump GT5 * EEC with MUI test * Include incomplete structure * REFLECTIONS !! * Just use slot filter * Update pos when needed * Update GT_MetaTileEntity_ExtremeExterminationChamber.java * Spawner status * Nice toggle button * Send messages * Next toggle button * Start work on IAADDS * Scrollable inventory test * Draw queen slots * Fix * Update dependencies.gradle * Use sync widget * Add button to enable/disable working * Configuration in Mega Apiary * Refactor a bit * Update ModularUI * Bump ModularUI * Bump GT5 * Fix build * Update dependencies.gradle * Update build.gradle * Update dependencies.gradle * spotless * Begin working on configuration window * Update dependencies.gradle * Deprecated * Update dependencies.gradle * Optimize bee storage rendering (2 fps -> 100 fps) * Make Mega Apiary storage GUI usable * Configuration window looks ok * Color is fixed * TC research * Disable for now * Finish tea command * ok * Fix * Update en_US.lang * ZzZ * Stuff changed
Diffstat (limited to 'src/main/java/kubatech/loaders/item/items/TeaUltimate.java')
-rw-r--r--src/main/java/kubatech/loaders/item/items/TeaUltimate.java160
1 files changed, 147 insertions, 13 deletions
diff --git a/src/main/java/kubatech/loaders/item/items/TeaUltimate.java b/src/main/java/kubatech/loaders/item/items/TeaUltimate.java
index 1119de63d3..8a1d11a41a 100644
--- a/src/main/java/kubatech/loaders/item/items/TeaUltimate.java
+++ b/src/main/java/kubatech/loaders/item/items/TeaUltimate.java
@@ -19,13 +19,34 @@
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;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.world.World;
-public class TeaUltimate extends TeaCollection {
+public class TeaUltimate extends TeaCollection implements IItemProxyGUI {
public TeaUltimate() {
super("ultimate_tea");
}
@@ -34,22 +55,135 @@ public class TeaUltimate extends TeaCollection {
private static long timeCounter = 0;
private static int colorCounter = 0;
+ public static String getUltimateTeaDisplayName(String displayName) {
+ long current = System.currentTimeMillis();
+ if (current - timeCounter > 100) {
+ timeCounter = current;
+ name = StringUtils.applyRainbow(
+ "ULTIMATE", colorCounter++, EnumChatFormatting.BOLD.toString() + EnumChatFormatting.OBFUSCATED);
+ }
+ return String.format(displayName, name + EnumChatFormatting.RESET);
+ }
+
@Override
public String getDisplayName(ItemStack stack) {
if (!ModUtils.isClientSided) return super.getDisplayName(stack);
- if (stack.stackTagCompound == null
- || (!stack.stackTagCompound.hasKey("TeaOwner")
- || stack.stackTagCompound
- .getString("TeaOwner")
- .equals(Minecraft.getMinecraft().thePlayer.getCommandSenderName()))) {
- long current = System.currentTimeMillis();
- if (current - timeCounter > 100) {
- timeCounter = current;
- name = StringUtils.applyRainbow(
- "ULTIMATE", colorCounter++, EnumChatFormatting.BOLD.toString() + EnumChatFormatting.OBFUSCATED);
- }
- return String.format(super.getDisplayName(stack), name + EnumChatFormatting.RESET);
+ if (checkTeaOwner(stack, Minecraft.getMinecraft().thePlayer.getCommandSenderName())) {
+ return getUltimateTeaDisplayName(super.getDisplayName(stack));
}
return EnumChatFormatting.GOLD + "" + EnumChatFormatting.BOLD + "" + EnumChatFormatting.ITALIC + "???????";
}
+
+ @Override
+ public ModularWindow createWindow(ItemStack stack, EntityPlayer player) {
+ ModularWindow.Builder builder = ModularWindow.builder(200, 150);
+ builder.setBackground(ModularUITextures.VANILLA_BACKGROUND);
+ final PlayerData playerData = PlayerDataManager.getPlayer(player.getCommandSenderName());
+ 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))*/ ));
+ return builder.build();
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer entity) {
+ if (world.isRemote) return stack;
+ if (!(entity instanceof EntityPlayerMP)) return stack;
+ if (!checkTeaOwner(stack, entity.getCommandSenderName())) return stack;
+ openHeldItemGUI(entity);
+ return stack;
+ }
+
+ @Override
+ public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isCurrentItem) {
+ if (world.isRemote) return;
+ if (!(entity instanceof EntityPlayerMP)) return;
+ super.onUpdate(stack, world, entity, slot, isCurrentItem);
+ if (checkTeaOwner(stack, entity.getCommandSenderName())) {
+ PlayerData playerData = PlayerDataManager.getPlayer(entity.getCommandSenderName());
+ if (playerData == null) return;
+ playerData.teaAmount++;
+ playerData.markDirty();
+
+ if (playerData.autoRegen && playerData.teaAmount > 75_000) {
+ if (((EntityPlayerMP) entity).getActivePotionEffect(Potion.regeneration) == null) {
+ ((EntityPlayerMP) entity).addPotionEffect(new PotionEffect(Potion.regeneration.id, 1200, 0, true));
+ playerData.teaAmount -= 75_000;
+ }
+ }
+ }
+ }
}