Skip to content

Commit

Permalink
Added magma boss bar to show health, disabled durability on tools whi…
Browse files Browse the repository at this point in the history
…le on skyblock, added a full inventory warning, other bug fixes and stuff.
  • Loading branch information
biscuut committed Jul 11, 2019
1 parent 966e55a commit 7e62bca
Show file tree
Hide file tree
Showing 14 changed files with 263 additions and 109 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
version = "1.0-b5"
version = "1.0-b6"
group= "codes.biscuit.skyblockaddons" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "SkyblockAddons"

Expand Down Expand Up @@ -60,7 +60,7 @@ repositories {
//}

dependencies {
provided('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
provided('org.spongepowered:mixin:0.7.11-SNAPSHOT') { //0.5.3-SNAPSHOT
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import codes.biscuit.skyblockaddons.commands.SkyblockAddonsCommand;
import codes.biscuit.skyblockaddons.listeners.PlayerListener;
import codes.biscuit.skyblockaddons.utils.ConfigValues;
import codes.biscuit.skyblockaddons.utils.Utils;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -14,11 +15,12 @@ public class SkyblockAddons {

static final String MOD_ID = "skyblockaddons";
static final String MOD_NAME = "SkyblockAddons";
public static final String VERSION = "1.0-b5";
public static final String VERSION = "1.0-b6";

public static SkyblockAddons INSTANCE; // for Mixins cause they don't have a constructor
private ConfigValues configValues;
private PlayerListener playerListener = new PlayerListener(this);
private Utils utils = new Utils(this);

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e) {
Expand All @@ -41,4 +43,8 @@ public ConfigValues getConfigValues() {
public PlayerListener getPlayerListener() {
return playerListener;
}

public Utils getUtils() {
return utils;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package codes.biscuit.skyblockaddons.gui;

public class ButtonSlider {
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,34 @@ public SkyblockAddonsGui(SkyblockAddons main) {
@Override
public void initGui() {
int halfWidth = width/2;
int oneThird = width/3;
int twoThirds = oneThird*2;
int boxWidth = 130;
int boxHeight = 20;
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-30, height*0.25, "Magma Boss Warning", main, Feature.MAGMA_WARNING, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth+30, height*0.25, "Item Drop Confirmation", main, Feature.DROP_CONFIRMATION, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-30, height*0.33, null, main, Feature.MANA_BAR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth+30, height*0.33, "Hide Skeleton Hat Bones", main, Feature.BONES, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-30, height*0.41, "Skeleton Hat Bones Bar", main, Feature.SKELETON_BAR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth+30, height*0.41, "Hide Food & Armor Bar", main, Feature.HIDE_FOOD_ARMOR_BAR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, oneThird-boxWidth-30, height*0.25, "Magma Boss Warning", main, Feature.MAGMA_WARNING, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-(boxWidth/2), height*0.25, "Item Drop Confirmation", main, Feature.DROP_CONFIRMATION, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, oneThird-boxWidth-30, height*0.33, null, main, Feature.MANA_BAR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-(boxWidth/2), height*0.33, "Hide Skeleton Hat Bones", main, Feature.BONES, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, oneThird-boxWidth-30, height*0.41, "Skeleton Hat Bones Bar", main, Feature.SKELETON_BAR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-(boxWidth/2), height*0.41, "Hide Food & Armor Bar", main, Feature.HIDE_FOOD_ARMOR_BAR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, oneThird-boxWidth-30, height*0.49, "Full Inventory Warning", main, Feature.FULL_INVENTORY_WARNING, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, twoThirds+30, height*0.25, "Magma Boss Bar", main, Feature.MAGMA_BOSS_BAR, boxWidth, boxHeight));
// buttonList.add(new ButtonRegular(0, oneThird-boxWidth-30, height*0.25, "Magma Boss Warning", main, Feature.MAGMA_WARNING, boxWidth, boxHeight));
// buttonList.add(new ButtonRegular(0, twoThirds+30, height*0.25, "Item Drop Confirmation", main, Feature.DROP_CONFIRMATION, boxWidth, boxHeight));
// buttonList.add(new ButtonRegular(0, oneThird-boxWidth-30, height*0.33, null, main, Feature.MANA_BAR, boxWidth, boxHeight));
// buttonList.add(new ButtonRegular(0, twoThirds+30, height*0.33, "Hide Skeleton Hat Bones", main, Feature.BONES, boxWidth, boxHeight));
// buttonList.add(new ButtonRegular(0, oneThird-boxWidth-30, height*0.41, "Skeleton Hat Bones Bar", main, Feature.SKELETON_BAR, boxWidth, boxHeight));
// buttonList.add(new ButtonRegular(0, twoThirds+30, height*0.41, "Hide Food & Armor Bar", main, Feature.HIDE_FOOD_ARMOR_BAR, boxWidth, boxHeight));
// buttonList.add(new ButtonRegular(0, twoThirds+30, height*0.49, "Full Inventory Warning", main, Feature.FULL_INVENTORY_WARNING, boxWidth, boxHeight));
boxWidth = 200;
buttonList.add(new ButtonRegular(0, halfWidth-100, height*0.49, "Disable Ember Rod Ability on Island", main, Feature.DISABLE_EMBER_ROD, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-(boxWidth/2), height*0.49, "Disable Ember Rod Ability on Island", main, Feature.DISABLE_EMBER_ROD, boxWidth, boxHeight));
boxWidth = 100;
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-20, height*0.65, "Warning Color", main, Feature.WARNING_COLOR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth+20, height*0.65, "Confirmation Color", main, Feature.CONFIRMATION_COLOR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-20, height*0.73, "Mana Text Color", main, Feature.MANA_TEXT_COLOR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth+20, height*0.73, "Mana Bar Color", main, Feature.MANA_BAR_COLOR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-20, height*0.81, null, main, Feature.WARNING_TIME, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-20, height*0.81, null, main, Feature.WARNING_TIME, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth+20, height*0.81, "Edit Locations", main, Feature.EDIT_LOCATIONS, boxWidth, boxHeight));
boxWidth = 20;
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-125, height*0.81, "+", main, Feature.ADD, boxWidth, boxHeight));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
import codes.biscuit.skyblockaddons.gui.LocationEditGui;
import codes.biscuit.skyblockaddons.gui.SkyblockAddonsGui;
import codes.biscuit.skyblockaddons.utils.Feature;
import codes.biscuit.skyblockaddons.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityMagmaCube;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
Expand All @@ -25,21 +26,26 @@
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.opengl.GL11;

import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Pattern;

import static net.minecraft.client.gui.Gui.icons;

public class PlayerListener {

public final static ItemStack BONE = new ItemStack(Item.getItemById(352));
private final static ResourceLocation manaBars = new ResourceLocation("skyblockaddons", "manabars.png");

private boolean sentUpdate = false;
private boolean predictMana = false;
private long lastWorldJoin = -1;
private int mana = 0;
private int maxMana = 100;
private boolean openGUI = false;
private boolean fullInventoryWarning = false;
private boolean bossWarning = false;
private long lastBoss = -1;
private int soundTick = 1;
Expand All @@ -55,6 +61,7 @@ public PlayerListener(SkyblockAddons main) {
@SubscribeEvent()
public void onWorldJoin(EntityJoinWorldEvent e) {
if (e.entity == Minecraft.getMinecraft().thePlayer) {
lastWorldJoin = System.currentTimeMillis();
bossWarning = false;
lastBoss = -1;
soundTick = 1;
Expand All @@ -64,23 +71,65 @@ public void onWorldJoin(EntityJoinWorldEvent e) {

@SubscribeEvent()
public void onRenderBossWarning(RenderGameOverlayEvent.Post e) {
if (bossWarning && e.type == RenderGameOverlayEvent.ElementType.TEXT) { // Render a title-like warning.
if (e.type == RenderGameOverlayEvent.ElementType.TEXT) { // Render a title-like warning.
Minecraft mc = Minecraft.getMinecraft();
ScaledResolution scaledresolution = e.resolution;
int i = scaledresolution.getScaledWidth();
int j = scaledresolution.getScaledHeight();
GlStateManager.pushMatrix();
GlStateManager.translate((float) (i / 2), (float) (j / 2), 0.0F);
if (bossWarning) {
int j = scaledresolution.getScaledHeight();
GlStateManager.pushMatrix();
GlStateManager.translate((float) (i / 2), (float) (j / 2), 0.0F);
// GlStateManager.enableBlend();
// GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.pushMatrix();
GlStateManager.scale(4.0F, 4.0F, 4.0F);
String text;
text = main.getConfigValues().getColor(Feature.WARNING_COLOR).getChatFormatting() + "MagmaCube Boss!";
mc.ingameGUI.getFontRenderer().drawString(text, (float) (-mc.ingameGUI.getFontRenderer().getStringWidth(text) / 2), -20.0F, 16777215, true);
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
GlStateManager.scale(4.0F, 4.0F, 4.0F);
String text;
text = main.getConfigValues().getColor(Feature.WARNING_COLOR).getChatFormatting() + "MagmaCube Boss!";
mc.ingameGUI.getFontRenderer().drawString(text, (float) (-mc.ingameGUI.getFontRenderer().getStringWidth(text) / 2), -20.0F, 16777215, true);
GlStateManager.popMatrix();
// GlStateManager.disableBlend();
GlStateManager.popMatrix();
GlStateManager.popMatrix();
}
if (fullInventoryWarning && !main.getConfigValues().getDisabledFeatures().contains(Feature.FULL_INVENTORY_WARNING)) {
int j = scaledresolution.getScaledHeight();
GlStateManager.pushMatrix();
GlStateManager.translate((float) (i / 2), (float) (j / 2), 0.0F);
GlStateManager.pushMatrix();
GlStateManager.scale(4.0F, 4.0F, 4.0F);
String text;
text = main.getConfigValues().getColor(Feature.WARNING_COLOR).getChatFormatting() + "Full Inventory!";
mc.ingameGUI.getFontRenderer().drawString(text, (float) (-mc.ingameGUI.getFontRenderer().getStringWidth(text) / 2), -20.0F, 16777215, true);
GlStateManager.popMatrix();
GlStateManager.popMatrix();
}
if (!main.getConfigValues().getDisabledFeatures().contains(Feature.MAGMA_BOSS_BAR)) {
for (Entity entity : mc.theWorld.loadedEntityList) {
if (entity instanceof EntityArmorStand) {
String name = entity.getDisplayName().getFormattedText();
if (name.contains("Magma Cube Boss ")) {
name = name.split(Pattern.quote("Magma Cube Boss "))[1];
mc.getTextureManager().bindTexture(icons);
GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GlStateManager.enableBlend();
int j = 182;
int k = i / 2 - j / 2;
int health = 1;
int l = (int) (health * (float) (j + 1));
int i1 = 12;
mc.ingameGUI.drawTexturedModalRect(k, i1, 0, 74, j, 5);
mc.ingameGUI.drawTexturedModalRect(k, i1, 0, 74, j, 5);

if (l > 0) {
mc.ingameGUI.drawTexturedModalRect(k, i1, 0, 79, l, 5);
}
mc.ingameGUI.getFontRenderer().drawStringWithShadow(name, (float) (i / 2 - mc.ingameGUI.getFontRenderer().getStringWidth(name) / 2), (float) (i1 - 10), 16777215);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(icons);
GlStateManager.disableBlend();
}
}
}
}
}
}

Expand Down Expand Up @@ -116,7 +165,7 @@ public void onChatReceive(ClientChatReceivedEvent e) {
@SubscribeEvent()
public void onRenderManaBar(RenderGameOverlayEvent.Post e) {
Minecraft mc = Minecraft.getMinecraft();
if (e.type == RenderGameOverlayEvent.ElementType.EXPERIENCE && Utils.isOnSkyblock()) {
if (e.type == RenderGameOverlayEvent.ElementType.EXPERIENCE && main.getUtils().isOnSkyblock()) {
if (main.getConfigValues().getManaBarType() != Feature.ManaBarType.OFF && !(mc.currentScreen instanceof LocationEditGui)) {
mc.getTextureManager().bindTexture(manaBars);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
Expand Down Expand Up @@ -178,7 +227,7 @@ public void onRenderManaBar(RenderGameOverlayEvent.Post e) {
@SubscribeEvent()
public void onRenderRemoveBars(RenderGameOverlayEvent.Pre e) {
if (e.type == RenderGameOverlayEvent.ElementType.ALL) {
if (Utils.isOnSkyblock() && !main.getConfigValues().getDisabledFeatures().contains(Feature.HIDE_FOOD_ARMOR_BAR)) {
if (main.getUtils().isOnSkyblock() && !main.getConfigValues().getDisabledFeatures().contains(Feature.HIDE_FOOD_ARMOR_BAR)) {
GuiIngameForge.renderFood = false;
GuiIngameForge.renderArmor = false;
}
Expand All @@ -189,11 +238,10 @@ public void onRenderRemoveBars(RenderGameOverlayEvent.Pre e) {
public void onInteract(PlayerInteractEvent e) {
if (!main.getConfigValues().getDisabledFeatures().contains(Feature.DISABLE_EMBER_ROD)) {
Minecraft mc = Minecraft.getMinecraft();
if (e.entityPlayer == mc.thePlayer && e.entityPlayer.getHeldItem() != null) {
if (mc.thePlayer.getHeldItem().getItem().getRegistryName().equals("minecraft:blaze_rod") && mc.thePlayer.getHeldItem().isItemEnchanted()) {
if (Utils.isOnIsland()) {
e.setCanceled(true);
}
ItemStack heldItem = e.entityPlayer.getHeldItem();
if (e.entityPlayer == mc.thePlayer && heldItem != null) {
if (heldItem.getItem().equals(Items.blaze_rod) && heldItem.isItemEnchanted() && main.getUtils().isOnIsland()) {
e.setCanceled(true);
}
}
}
Expand All @@ -208,11 +256,13 @@ public void onTickMana(TickEvent.ClientTickEvent e) {
mana += (maxMana/50);
if (mana>maxMana) mana = maxMana;
}
} else if (manaTick % 5 == 0) {
main.getUtils().checkIfInventoryIsFull();
} else if (manaTick > 20) {
Utils.checkIfOnSkyblockAndIsland();
main.getUtils().checkIfOnSkyblockAndIsland();
Minecraft mc = Minecraft.getMinecraft();
if (!sentUpdate && mc != null && mc.thePlayer != null && mc.theWorld != null) {
Utils.checkUpdates();
main.getUtils().checkUpdates();
sentUpdate = true;
}
manaTick = 1;
Expand All @@ -221,7 +271,7 @@ public void onTickMana(TickEvent.ClientTickEvent e) {
}

@SubscribeEvent()
public void onTickSound(TickEvent.ClientTickEvent e) {
public void onTickMagmaBossChecker(TickEvent.ClientTickEvent e) {
if (e.phase == TickEvent.Phase.START && !main.getConfigValues().getDisabledFeatures().contains(Feature.MAGMA_WARNING)) {
Minecraft mc = Minecraft.getMinecraft();
if (mc != null && mc.thePlayer != null) {
Expand Down Expand Up @@ -285,4 +335,16 @@ public void setOpenGUI(boolean openGUI) {
private boolean isOpenGUI() {
return openGUI;
}

public void setFullInventoryWarning(boolean fullInventoryWarning) {
this.fullInventoryWarning = fullInventoryWarning;
}

public boolean isFullInventoryWarning() {
return fullInventoryWarning;
}

public long getLastWorldJoin() {
return lastWorldJoin;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import codes.biscuit.skyblockaddons.SkyblockAddons;
import codes.biscuit.skyblockaddons.utils.Feature;
import codes.biscuit.skyblockaddons.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.item.EntityItem;
Expand All @@ -28,7 +27,7 @@ private void dropOneItemConfirmation(boolean dropAll, CallbackInfoReturnable<Ent
if (lastItem != null && lastItem == heldItem && System.currentTimeMillis() - lastDrop < 3000) {
lastDrop = System.currentTimeMillis();
} else {
Utils.sendMessage(SkyblockAddons.INSTANCE.getConfigValues().getColor(Feature.CONFIRMATION_COLOR).getChatFormatting() + "Drop this item again to confirm!");
SkyblockAddons.INSTANCE.getUtils().sendMessage(SkyblockAddons.INSTANCE.getConfigValues().getColor(Feature.CONFIRMATION_COLOR).getChatFormatting() + "Drop this item again to confirm!");
lastItem = heldItem;
lastDrop = System.currentTimeMillis();
cir.setReturnValue(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package codes.biscuit.skyblockaddons.mixins;

import codes.biscuit.skyblockaddons.utils.Utils;
import codes.biscuit.skyblockaddons.SkyblockAddons;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
Expand All @@ -19,7 +19,7 @@ public class MixinEntityRenderer {

@Inject(method = "getMouseOver", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 0), locals = LocalCapture.CAPTURE_FAILSOFT)
private void intersectsWith(float partialTicks, CallbackInfo ci, Entity entity, double d0, double d1, Vec3 vec3, boolean flag, boolean b, Vec3 vec31, Vec3 vec32, Vec3 vec33, float f, List<Entity> list, double d2, int i) {
if (Utils.isOnSkyblock()) { // conditions for the invisible zombie that Skeleton hat bones are riding
if (SkyblockAddons.INSTANCE.getUtils().isOnSkyblock()) { // conditions for the invisible zombie that Skeleton hat bones are riding
list.removeIf(listEntity -> listEntity instanceof EntityZombie && listEntity.isInvisible() && listEntity.riddenByEntity instanceof EntityItem);
}
}
Expand Down
Loading

0 comments on commit 7e62bca

Please sign in to comment.