aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMoulberry <james.jenour@student.scotch.wa.edu.au>2020-10-25 09:39:40 +1100
committerMoulberry <james.jenour@student.scotch.wa.edu.au>2020-10-25 09:39:40 +1100
commit3f86e881074dc4220aab23cae69f002c62f0b25a (patch)
tree47bab2c49730b0fadebde420209472d5d63757ad /src/main/java
parent7ebee833e54e95ffcd9dcfbad5744e299102acd9 (diff)
downloadNotEnoughUpdates-3f86e881074dc4220aab23cae69f002c62f0b25a.tar.gz
NotEnoughUpdates-3f86e881074dc4220aab23cae69f002c62f0b25a.tar.bz2
NotEnoughUpdates-3f86e881074dc4220aab23cae69f002c62f0b25a.zip
1.4.5
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java86
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java382
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java543
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java176
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java172
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java50
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/SettingsInfoPane.java259
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java70
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/Options.java205
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java15
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java95
22 files changed, 1691 insertions, 441 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java
index 1011f3cc..d8d84144 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java
@@ -4,6 +4,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats;
+import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -226,7 +227,7 @@ public class AccessoryBagOverlay {
private static Set<ItemStack> duplicates = null;
public static void renderDuplicatesOverlay(int x, int y) {
if(duplicates == null) {
- JsonObject misc = Utils.getConstant("misc");
+ JsonObject misc = Constants.MISC;
if(misc == null) {
Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
new Color(80, 80, 80).getRGB());
@@ -297,7 +298,7 @@ public class AccessoryBagOverlay {
private static List<ItemStack> missing = null;
public static void renderMissingOverlay(int x, int y) {
if(missing == null) {
- JsonObject misc = Utils.getConstant("misc");
+ JsonObject misc = Constants.MISC;
if(misc == null) {
Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
new Color(80, 80, 80).getRGB());
@@ -788,7 +789,7 @@ public class AccessoryBagOverlay {
}
public static boolean isAccessory(ItemStack stack) {
- return checkItemType(stack, false, "ACCESSORY", "HATCCESSORY") >= 0;
+ return checkItemType(stack, true, "ACCESSORY", "HATCCESSORY") >= 0;
}
public static int getRarity(ItemStack stack) {
@@ -800,7 +801,7 @@ public class AccessoryBagOverlay {
for (int i = list.tagCount(); i >= 0; i--) {
String line = list.getStringTagAt(i);
for(int j=0; j<rarityArrC.length; j++) {
- if(line.startsWith(rarityArrC[j])) {
+ if(line.contains(rarityArrC[j])) {
return j;
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java b/src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java
index 6a876201..1a7cd803 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java
@@ -25,6 +25,7 @@ import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
import java.util.Random;
public class BetterContainers {
@@ -43,14 +44,19 @@ public class BetterContainers {
private static int lastClickedSlot = 0;
private static int clickedSlot = 0;
private static long clickedSlotMillis = 0;
+ public static long lastRenderMillis = 0;
+
+ public static HashMap<Integer, ItemStack> itemCache = new HashMap<>();
+ public static boolean lastUsingCached = false;
+ public static boolean usingCached = false;
public static void clickSlot(int slot) {
- clickedSlot = slot;
clickedSlotMillis = System.currentTimeMillis();
+ clickedSlot = slot;
}
public static int getClickedSlot() {
- if(clickedSlotMillis - System.currentTimeMillis() < 200) {
+ if(System.currentTimeMillis() - clickedSlotMillis < 500) {
return clickedSlot;
}
return -1;
@@ -58,11 +64,32 @@ public class BetterContainers {
public static void bindHook(TextureManager textureManager, ResourceLocation location) {
if(isChestOpen()) {
- if(lastClickedSlot != getClickedSlot() || (texture == null && !loaded)) {
+ Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
+ if(container instanceof ContainerChest) {
+ usingCached = true;
+ IInventory lower = ((ContainerChest)container).getLowerChestInventory();
+ int size = lower.getSizeInventory();
+ for(int index=0; index<size; index++) {
+ if(lower.getStackInSlot(index) != null) {
+ for(int index2=0; index2<size; index2++) {
+ itemCache.put(index2, lower.getStackInSlot(index2));
+ }
+ usingCached = false;
+ break;
+ }
+ }
+ }
+
+ if((texture != null && loaded && lastClickedSlot != getClickedSlot()) ||
+ lastUsingCached != getUsingCache() ||
+ (texture == null && !loaded)) {
+ lastUsingCached = getUsingCache();
lastClickedSlot = getClickedSlot();
generateTex(location);
}
- if(isOverriding()) {
+ if(texture != null && loaded) {
+ if(!usingCached) lastRenderMillis = System.currentTimeMillis();
+ lastRenderMillis = System.currentTimeMillis();
textureManager.loadTexture(rl, texture);
textureManager.bindTexture(rl);
return;
@@ -71,6 +98,10 @@ public class BetterContainers {
textureManager.bindTexture(location);
}
+ public static boolean getUsingCache() {
+ return usingCached && System.currentTimeMillis() - lastRenderMillis < 300;
+ }
+
public static boolean isAh() {
if(!isChestOpen()) return false;
@@ -81,7 +112,7 @@ public class BetterContainers {
}
public static boolean isOverriding() {
- return isChestOpen() && loaded && texture != null && !Keyboard.isKeyDown(Keyboard.KEY_B);
+ return isChestOpen() && ((loaded && texture != null));
}
public static boolean isBlankStack(ItemStack stack) {
@@ -126,23 +157,24 @@ public class BetterContainers {
private static void generateTex(ResourceLocation location) {
if(!hasItem()) return;
+ texture = null;
loaded = true;
Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
- int backgroundStyle = NotEnoughUpdates.INSTANCE.manager.config.dynamicMenuBackgroundStyle.value.intValue();
- backgroundStyle = Math.max(1, Math.min(10, backgroundStyle));
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(
- new ResourceLocation("notenoughupdates:dynamic_54/style"+ backgroundStyle+"/dynamic_config.json")).getInputStream(), StandardCharsets.UTF_8));
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
- String textColourS = json.get("text-colour").getAsString();
- textColour = (int)Long.parseLong(textColourS, 16);
- } catch(Exception e) {
- textColour = 4210752;
- e.printStackTrace();
- }
-
if(hasNullPane() && container instanceof ContainerChest) {
+ int backgroundStyle = NotEnoughUpdates.INSTANCE.manager.config.dynamicMenuBackgroundStyle.value.intValue();
+ backgroundStyle = Math.max(1, Math.min(10, backgroundStyle));
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(
+ new ResourceLocation("notenoughupdates:dynamic_54/style"+ backgroundStyle+"/dynamic_config.json")).getInputStream(), StandardCharsets.UTF_8));
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
+ String textColourS = json.get("text-colour").getAsString();
+ textColour = (int)Long.parseLong(textColourS, 16);
+ } catch(Exception e) {
+ textColour = 4210752;
+ e.printStackTrace();
+ }
+
try {
BufferedImage bufferedImageOn = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(TOGGLE_ON).getInputStream());
BufferedImage bufferedImageOff = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(TOGGLE_OFF).getInputStream());
@@ -179,10 +211,10 @@ public class BetterContainers {
boolean[][] slots = new boolean[9][size/9];
boolean[][] buttons = new boolean[9][size/9];
for (int index = 0; index < size; index++) {
- ItemStack stack = lower.getStackInSlot(index);
+ ItemStack stack = getStackCached(lower, index);
buttons[index%9][index/9] = isButtonStack(stack);
- if(buttons[index%9][index/9] && getClickedSlot() == index) {
+ if(buttons[index%9][index/9] && lastClickedSlot == index) {
buttons[index%9][index/9] = false;
slots[index%9][index/9] = true;
} else {
@@ -190,7 +222,7 @@ public class BetterContainers {
}
}
for (int index = 0; index < size; index++) {
- ItemStack stack = lower.getStackInSlot(index);
+ ItemStack stack = getStackCached(lower, index);
int xi = index%9;
int yi = index/9;
if(slots[xi][yi] || buttons[xi][yi]) {
@@ -277,12 +309,20 @@ public class BetterContainers {
IInventory lower = ((ContainerChest)container).getLowerChestInventory();
int size = lower.getSizeInventory();
for(int index=0; index<size; index++) {
- if(lower.getStackInSlot(index) != null) return true;
+ if(getStackCached(lower, index) != null) return true;
}
}
return false;
}
+ private static ItemStack getStackCached(IInventory lower, int index) {
+ if(getUsingCache()) {
+ return itemCache.get(index);
+ } else {
+ return lower.getStackInSlot(index);
+ }
+ }
+
private static boolean hasNullPane() {
if(!isChestOpen()) return false;
Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
@@ -290,7 +330,7 @@ public class BetterContainers {
IInventory lower = ((ContainerChest)container).getLowerChestInventory();
int size = lower.getSizeInventory();
for(int index=0; index<size; index++) {
- if(isBlankStack(lower.getStackInSlot(index))) return true;
+ if(isBlankStack(getStackCached(lower, index))) return true;
}
}
return false;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java
index cc94981f..0fa4aa96 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java
@@ -1,38 +1,55 @@
package io.github.moulberry.notenoughupdates;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
+import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
+import net.minecraft.block.state.BlockState;
+import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.ActiveRenderInfo;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.WorldRenderer;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.*;
+import net.minecraft.client.renderer.block.model.BakedQuad;
+import net.minecraft.client.renderer.texture.TextureAtlasSprite;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
+import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.util.AxisAlignedBB;
-import net.minecraft.util.BlockPos;
-import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.nbt.CompressedStreamTools;
+import net.minecraft.nbt.NBTTagByteArray;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.util.*;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.client.event.EntityViewRenderEvent;
import net.minecraftforge.client.event.RenderBlockOverlayEvent;
+import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
+import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector3f;
+import scala.tools.cmd.Spec;
import java.awt.*;
-import java.util.HashSet;
-import java.util.LinkedList;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.*;
+import java.util.List;
public class CustomItemEffects {
public static final CustomItemEffects INSTANCE = new CustomItemEffects();
+ private static final int MAX_BUILDERS_BLOCKS = 164;
+
public long aoteUseMillis = 0;
public int aoteTeleportationMillis = 0;
public Vector3f aoteTeleportationCurr = null;
@@ -116,15 +133,118 @@ public class CustomItemEffects {
}
@SubscribeEvent
+ public void onOverlayDrawn(RenderGameOverlayEvent event) {
+ if(!NotEnoughUpdates.INSTANCE.manager.config.disableWandOverlay.value &&
+ Minecraft.getMinecraft().objectMouseOver != null &&
+ Minecraft.getMinecraft().objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK &&
+ ((event.type == null && Loader.isModLoaded("labymod")) ||
+ event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS)) {
+
+ IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState(
+ Minecraft.getMinecraft().objectMouseOver.getBlockPos().offset(
+ Minecraft.getMinecraft().objectMouseOver.sideHit, 1));
+ if(hover.getBlock() == Blocks.air) {
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+
+ if(heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ HashSet<BlockPos> candidatesOld = new HashSet<>();
+ TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>();
+
+ IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos());
+ Item matchItem = Item.getItemFromBlock(match.getBlock());
+ if(matchItem != null) {
+ ItemStack matchStack = new ItemStack(matchItem, 1,
+ match.getBlock().getDamageValue(Minecraft.getMinecraft().theWorld, Minecraft.getMinecraft().objectMouseOver.getBlockPos()));
+ int itemCount = countItemsInInventoryAndStorage(matchStack);
+
+ getBuildersWandCandidates(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().objectMouseOver, event.partialTicks,
+ candidatesOld, candidatesOldSorted, 999-MAX_BUILDERS_BLOCKS);
+
+ if(candidatesOld.size() > MAX_BUILDERS_BLOCKS) {
+ Utils.drawStringCentered(EnumChatFormatting.RED.toString()+candidatesOld.size()+"/"+MAX_BUILDERS_BLOCKS,
+ Minecraft.getMinecraft().fontRendererObj,
+ scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0);
+ } else {
+ String pre = EnumChatFormatting.GREEN.toString();
+ if(itemCount < candidatesOld.size()) {
+ pre = EnumChatFormatting.RED.toString();
+ }
+ Utils.drawStringCentered(pre+Math.min(candidatesOld.size(), itemCount)+"/"+
+ Math.min(candidatesOld.size(), MAX_BUILDERS_BLOCKS),
+ Minecraft.getMinecraft().fontRendererObj,
+ scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0);
+ }
+
+ String itemCountS = EnumChatFormatting.DARK_GRAY+"x"+EnumChatFormatting.RESET+countItemsInInventoryAndStorage(matchStack);
+ int itemCountLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(itemCountS);
+
+ if(NotEnoughUpdates.INSTANCE.manager.config.wandBlockCount.value) {
+ Utils.drawItemStack(matchStack, scaledResolution.getScaledWidth()/2 - (itemCountLen+16)/2, scaledResolution.getScaledHeight()/2+10+4);
+ Minecraft.getMinecraft().fontRendererObj.drawString(itemCountS,
+ scaledResolution.getScaledWidth()/2f - (itemCountLen+16)/2f+16, scaledResolution.getScaledHeight()/2f+10+8,
+ -1,
+ true);
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ }
+
+ }
+ }
+ }
+ }
+
+ public int countItemsInInventoryAndStorage(ItemStack match) {
+ int count = 0;
+
+ for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ if(match.isItemEqual(stack)) {
+ count += stack.stackSize;
+ }
+ }
+
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+
+ if(heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
+ //System.out.println("1");
+ if(held.hasTagCompound() && held.getTagCompound().hasKey("ExtraAttributes", 10) &&
+ held.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("builder's_wand_data", 7)) {
+ //System.out.println("2");
+ byte[] bytes = held.getTagCompound().getCompoundTag("ExtraAttributes").getByteArray("builder's_wand_data");
+ try {
+ NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
+ NBTTagList items = contents_nbt.getTagList("i", 10);
+ for(int j=0; j<items.tagCount(); j++) {
+ NBTTagCompound buildersItem = items.getCompoundTagAt(j);
+ if(buildersItem.getKeySet().size() > 0) {
+ if(buildersItem.getInteger("id") == Item.getIdFromItem(match.getItem())) {
+ count += items.getCompoundTagAt(j).getByte("Count");
+ }
+ }
+ }
+ } catch(Exception e) {
+ return count;
+ }
+ }
+ }
+
+ return count;
+ }
+
+ @SubscribeEvent
public void renderBlockOverlay(DrawBlockHighlightEvent event) {
if(aoteTeleportationCurr != null && aoteTeleportationMillis > 0) {
event.setCanceled(true);
}
- if(NotEnoughUpdates.INSTANCE.manager.config.disableTreecapOverlay.value) return;
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
if(heldInternal != null) {
- if(heldInternal.equals("JUNGLE_AXE") || heldInternal.equals("TREECAPITATOR_AXE")) {
+ if(!NotEnoughUpdates.INSTANCE.manager.config.disableTreecapOverlay.value &&
+ (heldInternal.equals("JUNGLE_AXE") || heldInternal.equals("TREECAPITATOR_AXE"))) {
int maxWood = 10;
if(heldInternal.equals("TREECAPITATOR_AXE")) maxWood = 35;
@@ -185,9 +305,9 @@ public class CustomItemEffects {
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)event.partialTicks;
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)event.partialTicks;
- drawSelectionBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
+ drawFilledBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
.expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2),
- random ? 0.5f : 1f);
+ random ? 0.5f : 1f, NotEnoughUpdates.INSTANCE.manager.config.treecapOverlayColour.value);
}
}
}
@@ -196,14 +316,205 @@ public class CustomItemEffects {
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
+ } else if(!NotEnoughUpdates.INSTANCE.manager.config.disableWandOverlay.value && heldInternal.equals("BUILDERS_WAND")) {
+ int maxBlocks = 164;
+ if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
+ IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos().offset(event.target.sideHit, 1));
+ if(hover.getBlock() == Blocks.air) {
+ EntityPlayer player = event.player;
+
+ IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos());
+ Item matchItem = Item.getItemFromBlock(match.getBlock());
+ if(matchItem != null) {
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+ GlStateManager.depthMask(false);
+
+ ItemStack matchStack = new ItemStack(matchItem, 1, match.getBlock().getMetaFromState(match));
+ int itemCount = countItemsInInventoryAndStorage(matchStack);
+
+ HashSet<BlockPos> candidatesOld = new HashSet<>();
+ TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>();
+
+ getBuildersWandCandidates(player, event.target, event.partialTicks, candidatesOld, candidatesOldSorted, 10);
+
+ String special = (candidatesOld.size() <= itemCount) ? NotEnoughUpdates.INSTANCE.manager.config.wandOverlayColour.value :
+ "0:255:255:0:0";
+
+ if(candidatesOld.size() <= maxBlocks) {
+ double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)event.partialTicks;
+ double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)event.partialTicks;
+ double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)event.partialTicks;
+
+ for(Set<BlockPos> candidatesSorted : candidatesOldSorted.values()) {
+ for(BlockPos candidate : candidatesSorted) {
+ match.getBlock().setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate);
+ AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
+ .offset(event.target.sideHit.getFrontOffsetX(), event.target.sideHit.getFrontOffsetY(),
+ event.target.sideHit.getFrontOffsetZ());
+
+ drawBlock((int)bb.minX, (int)bb.minY, (int)bb.minZ+1, match, event.partialTicks, 0.75f);
+ }
+ }
+
+ for(BlockPos candidate : candidatesOld) {
+ match.getBlock().setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate);
+ AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
+ .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2)
+ .offset(event.target.sideHit.getFrontOffsetX(), event.target.sideHit.getFrontOffsetY(),
+ event.target.sideHit.getFrontOffsetZ());
+
+ drawOutlineBoundingBox(bb, 1f, special);
+ }
+ }
+
+ GlStateManager.depthMask(true);
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+ }
+ }
+ }
}
}
}
- public static void drawSelectionBoundingBox(AxisAlignedBB p_181561_0_, float alpha) {
- Color c = new Color(SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.treecapOverlayColour.value), true);
+ public void getBuildersWandCandidates(EntityPlayer player, MovingObjectPosition target, float partialTicks,
+ HashSet<BlockPos> candidatesOld, TreeMap<Float, Set<BlockPos>> candidatesOldSorted, int extraMax) {
+ IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(target.getBlockPos());
+
+ candidatesOld.clear();
+ candidatesOldSorted.clear();
+ LinkedList<BlockPos> candidates = new LinkedList<>();
+ LinkedList<BlockPos> candidatesNew = new LinkedList<>();
+
+ candidatesNew.add(target.getBlockPos());
+
+ double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
+ double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
+ double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
+
+ while(candidatesOld.size() <= MAX_BUILDERS_BLOCKS+extraMax) {
+ if(candidatesNew.isEmpty()) {
+ break;
+ }
+
+ candidates.addAll(candidatesNew);
+ candidatesNew.clear();
+
+ while(!candidates.isEmpty()) {
+ if(candidatesOld.size() > MAX_BUILDERS_BLOCKS+extraMax) break;
+
+ BlockPos candidate = candidates.pop();
+
+ float distSq = (float)((candidate.getX()+0.5f-d0)*(candidate.getX()+0.5f-d0) +
+ (candidate.getY()+0.5f-d1-player.getEyeHeight())*(candidate.getY()+0.5f-d1-player.getEyeHeight()) +
+ (candidate.getZ()+0.5f-d2)*(candidate.getZ()+0.5f-d2));
+ candidatesOldSorted.computeIfAbsent(distSq, k->new Hash