Skip to content

Commit

Permalink
1.7.1: Important bug fixes (#123)
Browse files Browse the repository at this point in the history
Co-authored-by: symt <[email protected]>
  • Loading branch information
Detlev1 and symt authored Feb 13, 2024
1 parent 5601081 commit a0e1a0e
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 41 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

group = "dev.meyi.bazaarnotifier"
version = "1.7.0"
version = "1.7.1"
val mod_id = "bazaarnotifier"

java {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/meyi/bn/BazaarNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
public class BazaarNotifier {

public static final String MODID = "BazaarNotifier";
public static final String VERSION = "1.7.0";
public static final String VERSION = "1.7.1";
public static final String prefix =
EnumChatFormatting.GOLD + "[" + EnumChatFormatting.YELLOW + "BN" + EnumChatFormatting.GOLD
+ "] " + EnumChatFormatting.RESET;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/dev/meyi/bn/handlers/ChestTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void updateBazaarOrders(IInventory chest) {
break;
}
}
if (creator.equals(playerName)) {
if (creator.equals(playerName) || creator.isEmpty()) { //isEmpty for non Coop Islands
if (lore.get(4).toLowerCase().contains("expire") || lore.get(5).toLowerCase().contains("expire")) {
continue;
}
Expand All @@ -114,6 +114,7 @@ public static void updateBazaarOrders(IInventory chest) {
if (newOrder.getAmountRemaining() != 0) {
BazaarNotifier.orders.add(newOrder);
verifiedOrders = Arrays.copyOf(verifiedOrders, verifiedOrders.length + 1);
verifiedOrders[verifiedOrders.length-1] = 1;
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/dev/meyi/bn/json/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Order {
public int startAmount;
public double pricePerUnit;
public String priceString;
public OrderStatus orderStatus = OrderStatus.BEST;
public OrderStatus orderStatus = OrderStatus.SEARCHING;
public double orderValue;
public OrderType type;
private int amountRemaining;
Expand Down Expand Up @@ -54,12 +54,12 @@ public String getProductId() {
}

public void updateStatus() {
OrderStatus newOrderStatus = null;
OrderStatus newOrderStatus;
if (!BazaarNotifier.activeBazaar) {
return;
}
if (OrderType.BUY.equals(this.type)) {
if (BazaarNotifier.bazaarDataRaw.products.get(getProductId()).sell_summary.size() == 0) {
if (BazaarNotifier.bazaarDataRaw.products.get(getProductId()).sell_summary.isEmpty()) {
orderStatus = OrderStatus.SEARCHING;
return;
}
Expand All @@ -79,9 +79,11 @@ public void updateStatus() {
BazaarNotifier.orders.stream().filter(order -> this.product.equals(order.product)
&& this.pricePerUnit == order.pricePerUnit).count() != bazaarSubItem.orders) {
newOrderStatus = OrderStatus.MATCHED;
} else {
newOrderStatus = OrderStatus.BEST;
}
} else {
if (BazaarNotifier.bazaarDataRaw.products.get(getProductId()).buy_summary.size() == 0) {
if (BazaarNotifier.bazaarDataRaw.products.get(getProductId()).buy_summary.isEmpty()) {
orderStatus = OrderStatus.SEARCHING;
return;
}
Expand All @@ -100,6 +102,8 @@ public void updateStatus() {
BazaarNotifier.orders.stream().filter(order -> this.product.equals(order.product)
&& this.pricePerUnit == order.pricePerUnit).count() != bazaarSubItem.orders) {
newOrderStatus = OrderStatus.MATCHED;
} else {
newOrderStatus = OrderStatus.BEST;
}
}
if (this.orderStatus != newOrderStatus) {
Expand All @@ -125,5 +129,4 @@ public enum OrderType {
this.longName = longName;
}
}

}
31 changes: 14 additions & 17 deletions src/main/java/dev/meyi/bn/modules/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cc.polyfrost.oneconfig.config.annotations.Switch;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.hud.Hud;
import cc.polyfrost.oneconfig.platform.GuiPlatform;
import cc.polyfrost.oneconfig.platform.Platform;
import dev.meyi.bn.BazaarNotifier;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -36,24 +37,21 @@ public Module() {

@Override
protected boolean shouldShow() {
if(BazaarNotifier.inBazaar || Platform.getGuiPlatform().getCurrentScreen() != null){
//Drawing at this case is handled by the ChestTickHandler to keep it above the gray gui background;
return false;
}
if (showInGuis && Platform.getGuiPlatform().getCurrentScreen() != null &&
(Platform.getGuiPlatform().getCurrentScreen() instanceof OneConfigGui)) return false;
if(enabled) {
if (showInChat && Platform.getGuiPlatform().isInChat()) return true;
if (showInDebug && Platform.getGuiPlatform().isInDebug()) return true;
GuiPlatform guiPlatform = Platform.getGuiPlatform();
if(BazaarNotifier.inBazaar){
//Drawing at this case is handled by the ChestTickHandler to keep it above the gray gui background;
return false;
}
if (showInGuis && (guiPlatform.getCurrentScreen() instanceof OneConfigGui)) return false;
if (showInChat && guiPlatform.isInChat()) return true;
if (showInDebug && guiPlatform.isInDebug()) return true;
if (showInGuis && guiPlatform.getCurrentScreen() != null) return true;
return showEverywhere;
}else {
return false;
}
}

public boolean shouldShowGui(){
return enabled && (BazaarNotifier.inBazaar || showInGuis || showInChat || showInDebug || showEverywhere);
}
public abstract void draw();

protected abstract void reset();
Expand All @@ -75,8 +73,8 @@ public void handleMovement() {

public void drawBounds() {
if (shouldDrawBounds()) {
Gui.drawRect((int)position.getX() - padding, (int)position.getY() - padding,
(int)position.getRightX() + padding, (int)position.getBottomY() + padding, 0x66000000);
Gui.drawRect((int)position.getX(), (int)position.getY(),
(int)position.getRightX(), (int)position.getBottomY(), 0x66000000);
}
}

Expand Down Expand Up @@ -107,10 +105,9 @@ public void setActive(boolean active) {
}

public float getModuleWidth(){
return this.getWidth(scale, false) + 2 * padding;
return this.getWidth(scale, false);
}

public float getModuleHeight(){
return this.getHeight(scale, false) + 2 * padding;
}
return this.getHeight(scale, false); }
}
2 changes: 1 addition & 1 deletion src/main/java/dev/meyi/bn/modules/ModuleList.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void pageFlipCheck() {
public void drawAllGui(){
if (BazaarNotifier.config.enabled && BazaarNotifier.activeBazaar) {
for (Module m : this) {
if (m.shouldShowGui()) {
if (m.isEnabled() && BazaarNotifier.inBazaar) {
m.position.setSize(m.getModuleWidth(), m.getModuleHeight());
m.draw();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/dev/meyi/bn/modules/module/BankModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ protected void draw(UMatrixStack matrices, float x, float y, float scale, boolea

@Override
protected float getWidth(float scale, boolean example) {
return RenderUtils.getStringWidth(longestString)*scale;
return RenderUtils.getStringWidth(longestString)* scale + 2 * padding * scale;
}

@Override
protected float getHeight(float scale, boolean example) {
return ((Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT * lines) + lines )*scale - 2;
return (((Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT * lines) + lines ) * scale - 2) + 2 * padding * scale;
}


Expand Down Expand Up @@ -94,7 +94,7 @@ public void draw() {


longestString = RenderUtils.getLongestString(items);
RenderUtils.drawColorfulParagraph(items, (int)position.getX(), (int)position.getY(), scale);
RenderUtils.drawColorfulParagraph(items, (int)position.getX() + padding, (int)position.getY() + padding, scale);
GL11.glTranslated(0, 0, -1);
}

Expand Down
13 changes: 7 additions & 6 deletions src/main/java/dev/meyi/bn/modules/module/CraftingModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,16 @@ protected void draw(UMatrixStack matrices, float x, float y, float scale, boolea

@Override
protected float getWidth(float scale, boolean example) {
return RenderUtils.getStringWidth(longestString) * scale;
return RenderUtils.getStringWidth(longestString) * scale + 2 * padding * scale;
}

@Override
protected float getHeight(float scale, boolean example) {
try {
return (Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT
return ((Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT
* (BazaarNotifier.config.craftingModule.craftingListLength + 1)
+ (BazaarNotifier.config.craftingModule.craftingListLength + 1) * 2) * scale - 2;
+ (BazaarNotifier.config.craftingModule.craftingListLength + 1) * 2) * scale - 2)
+ 2 * scale * padding;
} catch (NullPointerException e) {
return 1;
}
Expand Down Expand Up @@ -243,7 +244,7 @@ public void draw() {
}
longestString = RenderUtils.getLongestString(items);

RenderUtils.drawColorfulParagraph(items, (int) position.getX(), (int) position.getY(), scale);
RenderUtils.drawColorfulParagraph(items, (int) position.getX() + padding, (int) position.getY() + padding, scale);
if (BazaarNotifier.inBazaar) {
renderMaterials(checkHoveredText(), list);
}
Expand Down Expand Up @@ -299,12 +300,12 @@ protected int getMaxShift() {
}

protected int checkHoveredText() {
float _y = position.getY() + 11 * scale;
float _y = position.getY() +(-padding + 11) * scale;
float y2 = _y + ((BazaarNotifier.config.craftingModule.craftingListLength) * 11 * scale);
int mouseYFormatted = getMouseCoordinateY();
float relativeYMouse = (mouseYFormatted - _y) / (11 * scale);
if (getWidth(scale, false) != 0) {
if (inMovementBox() && mouseYFormatted >= _y && mouseYFormatted <= y2 - 3 * scale) {
if (inMovementBox() && mouseYFormatted >= _y && mouseYFormatted <= y2) {
return (int) relativeYMouse + shift;
} else {
return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ protected void draw(UMatrixStack matrices, float x, float y, float scale, boolea
protected float getWidth(float scale, boolean example) {
if (longestString != null) {
if (!longestString.isEmpty()) {
return RenderUtils.getStringWidth(longestString) * scale;
return RenderUtils.getStringWidth(longestString) * scale + 2 * padding * scale;
}
}
return 200*scale;
}

@Override
protected float getHeight(float scale, boolean example) {
return (Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT * 10 + 20)*scale - 2;
return ((Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT * 10 + 20) * scale - 2) + 2 * padding * scale;
}
//source dsm
public static void drawOnSlot(int chestSize, int slot, int color) {
Expand Down Expand Up @@ -105,7 +105,7 @@ public void draw() {
items.add(message);
}
longestString = RenderUtils.getLongestString(items);
RenderUtils.drawColorfulParagraph(items, (int)position.getX(), (int)position.getY(), scale);
RenderUtils.drawColorfulParagraph(items, (int)position.getX() + padding, (int)position.getY() + padding, scale);
} else {
longestString = "";
RenderUtils.drawCenteredString("No orders found", (int)position.getX(), (int)position.getY(), 0xAAAAAA, scale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected void draw(UMatrixStack matrices, float x, float y, float scale, boolea

@Override
protected float getWidth(float scale, boolean example) {
return RenderUtils.getStringWidth(longestString)*scale;
return RenderUtils.getStringWidth(longestString)*scale + 2 * padding * scale;
}

@Override
Expand All @@ -61,7 +61,8 @@ protected float getHeight(float scale, boolean example) {
}
return (Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT
* BazaarNotifier.config.suggestionModule.suggestionListLength
+ BazaarNotifier.config.suggestionModule.suggestionListLength * 2)*scale - 2;
+ BazaarNotifier.config.suggestionModule.suggestionListLength * 2)*scale - 2
+ 2 * padding * scale;
}

@Override
Expand All @@ -81,7 +82,7 @@ public void draw() {
items.add(message);
}
longestString = RenderUtils.getLongestString(items);
RenderUtils.drawColorfulParagraph(items, (int)position.getX(), (int)position.getY(), scale);
RenderUtils.drawColorfulParagraph(items, (int)position.getX() + padding, (int)position.getY() + padding, scale);
} else {
RenderUtils.drawCenteredString("Waiting for bazaar data", (int)position.getX(), (int)position.getY(), 0xAAAAAA, scale);
//Todo add height and width
Expand Down

0 comments on commit a0e1a0e

Please sign in to comment.