diff options
author | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2023-07-25 15:11:10 +0800 |
---|---|---|
committer | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2023-07-30 12:21:37 +0800 |
commit | bca948cc7a9630ebe380590f0f036e1d5ef2ee99 (patch) | |
tree | 22ddaa996ded9523ea3d945e90187d1e2c36e125 /src/main/java/me/xmrvizzy/skyblocker/skyblock | |
parent | 9004f3fd4401cb6fe97232634b35c9f168b51ca9 (diff) | |
download | Skyblocker-bca948cc7a9630ebe380590f0f036e1d5ef2ee99.tar.gz Skyblocker-bca948cc7a9630ebe380590f0f036e1d5ef2ee99.tar.bz2 Skyblocker-bca948cc7a9630ebe380590f0f036e1d5ef2ee99.zip |
Refactor mixins
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock')
5 files changed, 26 insertions, 37 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/OldLever.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/OldLever.java index 37320c92..13789fe1 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/OldLever.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dungeon/OldLever.java @@ -7,11 +7,11 @@ import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShape; public class OldLever { - protected static final VoxelShape FLOOR_SHAPE; - protected static final VoxelShape NORTH_SHAPE; - protected static final VoxelShape SOUTH_SHAPE; - protected static final VoxelShape EAST_SHAPE; - protected static final VoxelShape WEST_SHAPE; + protected static final VoxelShape FLOOR_SHAPE = Block.createCuboidShape(4.0D, 0.0D, 4.0D, 12.0D, 10.0D, 12.0D); + protected static final VoxelShape NORTH_SHAPE = Block.createCuboidShape(5.0D, 3.0D, 10.0D, 11.0D, 13.0D, 16.0D); + protected static final VoxelShape SOUTH_SHAPE = Block.createCuboidShape(5.0D, 3.0D, 0.0D, 11.0D, 13.0D, 6.0D); + protected static final VoxelShape EAST_SHAPE = Block.createCuboidShape(0.0D, 3.0D, 5.0D, 6.0D, 13.0D, 11.0D); + protected static final VoxelShape WEST_SHAPE = Block.createCuboidShape(10.0D, 3.0D, 5.0D, 16.0D, 13.0D, 11.0D); public static VoxelShape getShape(WallMountLocation wallMountLocation, Direction direction) { if (!SkyblockerConfig.get().general.hitbox.oldLeverHitbox) @@ -37,12 +37,4 @@ public class OldLever { } return null; } - - static { - FLOOR_SHAPE = Block.createCuboidShape(4, 0, 4, 12, 10, 12); - NORTH_SHAPE = Block.createCuboidShape(5.0D, 3.0D, 10.0D, 11.0D, 13.0D, 16.0D); - SOUTH_SHAPE = Block.createCuboidShape(5.0D, 3.0D, 0.0D, 11.0D, 13.0D, 6.0D); - WEST_SHAPE = Block.createCuboidShape(10.0D, 3.0D, 5.0D, 16.0D, 13.0D, 11.0D); - EAST_SHAPE = Block.createCuboidShape(0.0D, 3.0D, 5.0D, 6.0D, 13.0D, 11.0D); - } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/ItemListWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/ItemListWidget.java index 3a1f91d3..04dc6820 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/ItemListWidget.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/itemlist/ItemListWidget.java @@ -1,7 +1,7 @@ package me.xmrvizzy.skyblocker.skyblock.itemlist; import com.mojang.blaze3d.systems.RenderSystem; -import me.xmrvizzy.skyblocker.mixin.RecipeBookWidgetAccessor; +import me.xmrvizzy.skyblocker.mixin.accessor.RecipeBookWidgetAccessor; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -15,7 +15,7 @@ import net.minecraft.screen.AbstractRecipeScreenHandler; import net.minecraft.text.Text; import net.minecraft.util.Formatting; -@Environment(value= EnvType.CLIENT) +@Environment(value = EnvType.CLIENT) public class ItemListWidget extends RecipeBookWidget implements Drawable, Selectable { private int parentWidth; private int parentHeight; @@ -23,10 +23,12 @@ public class ItemListWidget extends RecipeBookWidget implements Drawable, Select private TextFieldWidget searchField; private SearchResultsWidget results; - public ItemListWidget() { super(); } + public ItemListWidget() { + super(); + } public void updateSearchResult() { - this.results.updateSearchResult(((RecipeBookWidgetAccessor)this).getSearchText()); + this.results.updateSearchResult(((RecipeBookWidgetAccessor) this).getSearchText()); } @Override @@ -35,7 +37,7 @@ public class ItemListWidget extends RecipeBookWidget implements Drawable, Select this.parentWidth = parentWidth; this.parentHeight = parentHeight; this.leftOffset = narrow ? 0 : 86; - this.searchField = ((RecipeBookWidgetAccessor)this).getSearchField(); + this.searchField = ((RecipeBookWidgetAccessor) this).getSearchField(); int x = (this.parentWidth - 147) / 2 - this.leftOffset; int y = (this.parentHeight - 166) / 2; if (ItemRegistry.filesImported) { @@ -48,14 +50,14 @@ public class ItemListWidget extends RecipeBookWidget implements Drawable, Select public void render(DrawContext context, int mouseX, int mouseY, float delta) { if (this.isOpen()) { MatrixStack matrices = context.getMatrices(); - matrices.push(); + matrices.push(); matrices.translate(0.0D, 0.0D, 100.0D); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - this.searchField = ((RecipeBookWidgetAccessor)this).getSearchField(); + this.searchField = ((RecipeBookWidgetAccessor) this).getSearchField(); int i = (this.parentWidth - 147) / 2 - this.leftOffset; int j = (this.parentHeight - 166) / 2; context.drawTexture(TEXTURE, i, j, 1, 1, 147, 166); - this.searchField = ((RecipeBookWidgetAccessor)this).getSearchField(); + this.searchField = ((RecipeBookWidgetAccessor) this).getSearchField(); if (!ItemRegistry.filesImported && !this.searchField.isFocused() && this.searchField.getText().isEmpty()) { Text hintText = (Text.literal("Loading...")).formatted(Formatting.ITALIC).formatted(Formatting.GRAY); @@ -66,7 +68,7 @@ public class ItemListWidget extends RecipeBookWidget implements Drawable, Select } else { this.searchField.render(context, mouseX, mouseY, delta); } - if (ItemRegistry.filesImported){ + if (ItemRegistry.filesImported) { if (results == null) { int x = (this.parentWidth - 147) / 2 - this.leftOffset; int y = (this.parentHeight - 166) / 2; @@ -88,15 +90,15 @@ public class ItemListWidget extends RecipeBookWidget implements Drawable, Select @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (this.isOpen() && !this.client.player.isSpectator() && ItemRegistry.filesImported && results != null) { - if (this.searchField != null && this.searchField.mouseClicked(mouseX, mouseY, button)) { + if (this.isOpen() && this.client.player != null && !this.client.player.isSpectator() && ItemRegistry.filesImported && this.searchField != null && results != null) { + if (this.searchField.mouseClicked(mouseX, mouseY, button)) { this.results.closeRecipeView(); this.searchField.setFocused(true); return true; - } else - this.searchField.setFocused(false); + } else { + this.searchField.setFocused(false); return this.results.mouseClicked(mouseX, mouseY, button); - } else - return false; + } + } else return false; } }
\ No newline at end of file diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNavButton.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNavButton.java index c02463a3..d9e97976 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNavButton.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/quicknav/QuickNavButton.java @@ -3,7 +3,7 @@ package me.xmrvizzy.skyblocker.skyblock.quicknav; import com.mojang.blaze3d.systems.RenderSystem; import me.xmrvizzy.skyblocker.SkyblockerMod; -import me.xmrvizzy.skyblocker.mixin.HandledScreenAccessor; +import me.xmrvizzy.skyblocker.mixin.accessor.HandledScreenAccessor; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -19,7 +19,6 @@ import net.minecraft.util.Identifier; @Environment(value=EnvType.CLIENT) public class QuickNavButton extends ClickableWidget { - private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); private static final Identifier BUTTON_TEXTURE = new Identifier("textures/gui/container/creative_inventory/tabs.png"); private final int index; @@ -42,12 +41,9 @@ public class QuickNavButton extends ClickableWidget { if (screen instanceof HandledScreen<?> handledScreen) { int x = ((HandledScreenAccessor)handledScreen).getX(); int y = ((HandledScreenAccessor)handledScreen).getY(); - int w = ((HandledScreenAccessor)handledScreen).getBackgroundWidth(); int h = ((HandledScreenAccessor)handledScreen).getBackgroundHeight(); if (h > 166) --h; // why is this even a thing - // this.x = x + this.index % 6 * 28 + 4; this.setX(x + this.index % 6 * 26 + 4); - // this.y = this.index < 6 ? y - 28 : y + h - 4; this.setY(this.index < 6 ? y - 26 : y + h - 4); this.u = 26; this.v = (index < 6 ? 0 : 64) + (toggled ? 32 : 0); diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java index fed34796..aa730c31 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/rift/HealingMelonIndicator.java @@ -12,12 +12,12 @@ import net.minecraft.util.Formatting; public class HealingMelonIndicator { private static final Title title = new Title("skyblocker.rift.healNow", Formatting.DARK_RED); - public static void updateHealth(MinecraftClient client) { + public static void updateHealth() { if (!SkyblockerConfig.get().slayer.vampireSlayer.enableHealingMelonIndicator || !Utils.isOnSkyblock() || !Utils.isInTheRift() || !Utils.getLocation().contains("Stillgore Château")) { TitleContainer.removeTitle(title); return; } - ClientPlayerEntity player = client.player; + ClientPlayerEntity player = MinecraftClient.getInstance().player; if (player != null && player.getHealth() <= SkyblockerConfig.get().slayer.vampireSlayer.healingMelonHealthThreshold * 2F) { RenderHelper.displayInTitleContainerAndPlaySound(title); } else { diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java index ee4319dc..d0ce6b72 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java @@ -4,11 +4,10 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import me.xmrvizzy.skyblocker.mixin.PlayerListHudAccessor; +import me.xmrvizzy.skyblocker.mixin.accessor.PlayerListHudAccessor; import me.xmrvizzy.skyblocker.utils.Utils; import net.minecraft.client.MinecraftClient; |