diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/module/TotemOfHoldingModule.java b/src/main/java/org/violetmoon/quark/addons/oddities/module/TotemOfHoldingModule.java index 7302aa605a..20b5ef38d6 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/module/TotemOfHoldingModule.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/module/TotemOfHoldingModule.java @@ -54,9 +54,6 @@ public class TotemOfHoldingModule extends ZetaModule { @Config(description = "Set this to false to only allow the owner of a totem to collect its items rather than any player") public static boolean allowAnyoneToCollect = true; - @Config(flag = "soul_compass") - public static boolean enableSoulCompass = true; - @LoadEvent public final void register(ZRegister event) { totemType = EntityType.Builder.of(TotemOfHoldingEntity::new, MobCategory.MISC) diff --git a/src/main/java/org/violetmoon/quark/content/experimental/client/screen/VariantSelectorScreen.java b/src/main/java/org/violetmoon/quark/content/experimental/client/screen/VariantSelectorScreen.java index 296a6aadf1..38149bdf98 100644 --- a/src/main/java/org/violetmoon/quark/content/experimental/client/screen/VariantSelectorScreen.java +++ b/src/main/java/org/violetmoon/quark/content/experimental/client/screen/VariantSelectorScreen.java @@ -8,9 +8,9 @@ import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; +import com.mojang.datafixers.util.Pair; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.GameRenderer; @@ -18,198 +18,204 @@ import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; -import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.lwjgl.opengl.GL11; +import org.violetmoon.quark.content.experimental.item.HammerItem; import org.violetmoon.quark.content.experimental.module.VariantSelectorModule; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class VariantSelectorScreen extends Screen { - private float timeIn = 0; - private int slotSelected = -1; + private float timeIn = 0; + private int slotSelected = -1; - private final Minecraft mc; - private final ItemStack stack; - private final KeyMapping key; - private final String currentVariant; - private final List variants; + private final Minecraft mc; + private final KeyMapping key; + private final String currentVariant; + private final List> variants; + + private final List drawStacks = new ArrayList<>(); - private final List drawStacks = new ArrayList<>(); - - public VariantSelectorScreen(ItemStack stack, KeyMapping key, String currentVariant, List variants) { - super(Component.empty()); - mc = Minecraft.getInstance(); - this.stack = stack; - this.key = key; - this.currentVariant = currentVariant; - this.variants = variants; - } - - @Override - public void render(@NotNull GuiGraphics guiGraphics, int mx, int my, float delta) { - super.render(guiGraphics, mx, my, delta); - - timeIn += delta; - - int x = width / 2; - int y = height / 2; - int maxRadius = 50; - - int segments = variants.size() + 1; - float degPer = (float) Math.PI * 2 / segments; - - // ensure the boring one is always at the bottom - float pad = -((float) Math.PI / segments) + ((float) Math.PI / 2); - double angle = mouseAngle(x, y, mx, my); - double dist = (x - mx) * (x - mx) + (y - my) * (y - my); - - // loop angle around to ensure the last bit is accessible - if(angle < pad) - angle = Math.PI * 2 + pad; - - slotSelected = -1; - - Block block = Blocks.COBBLESTONE; - if(stack.getItem() instanceof BlockItem bi) - block = bi.getBlock(); - - Tesselator tess = Tesselator.getInstance(); - BufferBuilder buf = tess.getBuilder(); - - RenderSystem.disableCull(); - RenderSystem.enableBlend(); - RenderSystem.setShader(GameRenderer::getPositionColorShader); - - drawStacks.clear(); - buf.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR); - - for(int seg = 0; seg < segments; seg++) { - String variant = seg == 0 ? "" : variants.get(seg - 1); - boolean rightVariant = variant.equals(currentVariant); - - Block variantBlock = VariantSelectorModule.getVariantForBlock(block, variant); - boolean variantExists = seg == 0 || (variantBlock != block); - - float start = seg * degPer + pad; - float end = (seg + 1) * degPer + pad; - - boolean mouseInSector = variantExists && start < angle && angle < end && dist > 64; - float radius = Math.max(0F, Math.min((timeIn - ((float) seg * 6F / (float) segments)) * 40F, (float) maxRadius)); - - if(mouseInSector || rightVariant) - radius *= 1.1f; - - if(!variantExists) - radius *= 0.9f; - - int gs = 0x39; - if(seg % 2 == 0) - gs += 0x29; - - int r = gs; - int g = gs; - int b = gs; - int a = 0x44; - - if(variantExists) { - g += 0x22; - a = 0x99; - } else { - r /= 4; - g /= 4; - b /= 4; - } - - if(seg == 0) - buf.vertex(x, y, 0).color(r, g, b, a).endVertex(); - - if(mouseInSector) { - slotSelected = seg; - r = 0x00; - g = b = 0xAA; - } else if(rightVariant) { - r = b = 0x00; - g = 0xAA; - } - - float sxp = x + Mth.cos(start) * radius; - float syp = y + Mth.sin(start) * radius; - float exp = x + Mth.cos(end) * radius; - float eyp = y + Mth.sin(end) * radius; - - buf.vertex(sxp, syp, 0).color(r, g, b, a).endVertex(); - buf.vertex(exp, eyp, 0).color(r, g, b, a).endVertex(); - - float center = (seg + 0.5f) * degPer + pad; - float cxp = x + Mth.cos(center) * radius; - float cyp = y + Mth.sin(center) * radius; - - ItemStack variantStack = variantExists ? new ItemStack(variantBlock) : ItemStack.EMPTY; - double mod = 0.6; - int xdp = (int) ((cxp - x) * mod + x); - int ydp = (int) ((cyp - y) * mod + y); - drawStacks.add(new DrawStack(variantStack, xdp - 8, ydp - 8)); - } - tess.end(); - - RenderSystem.enableBlend(); - RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - - for(DrawStack ds : drawStacks) { - if(!ds.stack().isEmpty()) - guiGraphics.renderItem(ds.stack(), ds.x(), ds.y()); - } - RenderSystem.disableBlend(); - } - - @Override - public void tick() { - super.tick(); - if(!isKeyDown(key)) { - mc.setScreen(null); - - if(slotSelected == -1 && timeIn < 10) - slotSelected = 0; - - if(slotSelected != -1) { - String variant = slotSelected == 0 ? "" : variants.get(slotSelected - 1); - VariantSelectorModule.Client.setClientVariant(variant, true); - mc.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - } - } - - ImmutableSet set = ImmutableSet.of(mc.options.keyUp, mc.options.keyLeft, mc.options.keyDown, mc.options.keyRight, mc.options.keyShift, mc.options.keySprint, mc.options.keyJump); - for(KeyMapping k : set) { - KeyMapping.set(k.getKey(), isKeyDown(k)); - } - } - - public boolean isKeyDown(KeyMapping keybind) { - InputConstants.Key key = keybind.getKey(); - if(key.getType() == InputConstants.Type.MOUSE) { - return keybind.isDown(); - } - return InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), key.getValue()); - } - - @Override - public boolean isPauseScreen() { - return false; - } - - private static double mouseAngle(int x, int y, int mx, int my) { - return (Mth.atan2(my - y, mx - x) + Math.PI * 2) % (Math.PI * 2); - } - - private record DrawStack(ItemStack stack, int x, int y) { - }; + public VariantSelectorScreen(Block originalBlock, KeyMapping key, String currentVariant, List visibleVariants) { + super(Component.empty()); + this.mc = Minecraft.getInstance(); + this.key = key; + this.currentVariant = currentVariant; + + this.variants = new ArrayList<>(); + this.variants.add(Pair.of("", originalBlock)); + for(String v : visibleVariants){ + Block variantBlock = VariantSelectorModule.getVariantBlockFromOriginal(originalBlock, v); + variants.add(Pair.of(v, variantBlock)); + } + } + + @Override + public void render(@NotNull GuiGraphics guiGraphics, int mx, int my, float delta) { + super.render(guiGraphics, mx, my, delta); + + timeIn += delta; + + int x = width / 2; + int y = height / 2; + int maxRadius = 50; + + int segments = variants.size() ; + float degPer = (float) Math.PI * 2 / segments; + + // ensure the boring one is always at the bottom + float pad = -((float) Math.PI / segments) + ((float) Math.PI / 2); + double angle = mouseAngle(x, y, mx, my); + double dist = (x - mx) * (x - mx) + (y - my) * (y - my); + + // loop angle around to ensure the last bit is accessible + if (angle < pad) + angle = Math.PI * 2 + pad; + + slotSelected = -1; + + Tesselator tess = Tesselator.getInstance(); + BufferBuilder buf = tess.getBuilder(); + + RenderSystem.disableCull(); + RenderSystem.enableBlend(); + RenderSystem.setShader(GameRenderer::getPositionColorShader); + + drawStacks.clear(); + buf.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR); + + for (int seg = 0; seg < segments; seg++) { + //we need 1 extra + var pair = variants.get(seg); + String variant = pair.getFirst(); + Block variantBlock = pair.getSecond(); + boolean variantExists = variantBlock != null; + + boolean rightVariant = variant.equals(currentVariant); + + float start = seg * degPer + pad; + float end = (seg + 1) * degPer + pad; + + boolean mouseInSector = variantExists && start < angle && angle < end && dist > 64; + float radius = Math.max(0F, Math.min((timeIn - ((float) seg * 6F / (float) segments)) * 40F, (float) maxRadius)); + + if (mouseInSector || rightVariant) + radius *= 1.1f; + + if (!variantExists) + radius *= 0.9f; + + int gs = 0x39; + if (seg % 2 == 0) + gs += 0x29; + + int r = gs; + int g = gs; + int b = gs; + int a = 0x44; + + if (variantExists) { + g += 0x22; + a = 0x99; + } else { + r /= 4; + g /= 4; + b /= 4; + } + + if (seg == 0) + buf.vertex(x, y, 0).color(r, g, b, a).endVertex(); + + if (mouseInSector) { + slotSelected = seg; + r = 0x00; + g = b = 0xAA; + } else if (rightVariant) { + r = b = 0x00; + g = 0xAA; + } + + float sxp = x + Mth.cos(start) * radius; + float syp = y + Mth.sin(start) * radius; + float exp = x + Mth.cos(end) * radius; + float eyp = y + Mth.sin(end) * radius; + + buf.vertex(sxp, syp, 0).color(r, g, b, a).endVertex(); + buf.vertex(exp, eyp, 0).color(r, g, b, a).endVertex(); + + float center = (seg + 0.5f) * degPer + pad; + float cxp = x + Mth.cos(center) * radius; + float cyp = y + Mth.sin(center) * radius; + + ItemStack variantStack = variantExists ? new ItemStack(variantBlock) : ItemStack.EMPTY; + double mod = 0.6; + int xdp = (int) ((cxp - x) * mod + x); + int ydp = (int) ((cyp - y) * mod + y); + drawStacks.add(new DrawStack(variantStack, xdp - 8, ydp - 8)); + } + tess.end(); + + RenderSystem.enableBlend(); + RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + + for (DrawStack ds : drawStacks) { + if (!ds.stack().isEmpty()) + guiGraphics.renderItem(ds.stack(), ds.x(), ds.y()); + } + RenderSystem.disableBlend(); + } + + @Override + public void tick() { + super.tick(); + if (!isKeyDown(key)) { + mc.setScreen(null); + + if (slotSelected == -1 && timeIn < 10) + slotSelected = 0; + + if (slotSelected != -1) { + String variant = variants.get(slotSelected).getFirst(); + VariantSelectorModule.Client.setClientVariant(variant, true); + mc.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + } + } + + ImmutableSet set = ImmutableSet.of(mc.options.keyUp, mc.options.keyLeft, mc.options.keyDown, mc.options.keyRight, mc.options.keyShift, mc.options.keySprint, mc.options.keyJump); + for (KeyMapping k : set) { + KeyMapping.set(k.getKey(), isKeyDown(k)); + } + } + + public boolean isKeyDown(KeyMapping keybind) { + InputConstants.Key key = keybind.getKey(); + if (key.getType() == InputConstants.Type.MOUSE) { + return keybind.isDown(); + } + return InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), key.getValue()); + } + + @Override + public boolean isPauseScreen() { + return false; + } + + private static double mouseAngle(int x, int y, int mx, int my) { + return (Mth.atan2(my - y, mx - x) + Math.PI * 2) % (Math.PI * 2); + } + + private record DrawStack(ItemStack stack, int x, int y) { + } + + ; } diff --git a/src/main/java/org/violetmoon/quark/content/experimental/config/VariantsConfig.java b/src/main/java/org/violetmoon/quark/content/experimental/config/VariantsConfig.java index 58e67a86d7..71408df2a1 100644 --- a/src/main/java/org/violetmoon/quark/content/experimental/config/VariantsConfig.java +++ b/src/main/java/org/violetmoon/quark/content/experimental/config/VariantsConfig.java @@ -8,6 +8,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.violetmoon.quark.base.Quark; import org.violetmoon.zeta.config.Config; @@ -106,18 +107,6 @@ public void onReload(ZetaModule module, ConfigFlagManager flagManager) { logVariantMap(); } - // gets variant key for a block given its base block - @Nullable - public String getVariantForBlock(Block baseBlock, Block possibleVariant) { - VariantMap map = getVariants(baseBlock); - if(map != null){ - for(Entry entry : map.variants.entrySet()) - if(entry.getValue().equals(possibleVariant)) - return entry.getKey(); - } - return null; - } - @Nullable public String findVariantForBlock(Block variantBlock) { String name = BuiltInRegistries.BLOCK.getKey(variantBlock).getPath(); @@ -135,19 +124,30 @@ public String findVariantForBlock(Block variantBlock) { return null; } - public Block getBlockForVariant(Block block, String variant) { - blockVariants.clear(); - if(variant == null || !sortedSuffixes.contains(variant)) - return block; + // Null if not valid string, Not an original block or block wasn't changed (variant wasnt found) + @Nullable + public Block getBlockOfVariant(Block baseBlock, @NotNull String variant) { + //not a valid string + if(!sortedSuffixes.contains(variant)) + return null; - VariantMap map = getVariants(block); - Block ret = map.variants.get(variant); - if(ret != null) - return ret; + VariantMap map = getVariants(baseBlock); + return map.variants.get(variant); + } - return block; + // gets variant key for a block given its base block. Inverse of above + @Nullable + public String getVariantOfBlock(Block baseBlock, Block possibleVariant) { + VariantMap map = getVariants(baseBlock); + if(map != null){ + for(Entry entry : map.variants.entrySet()) + if(entry.getValue().equals(possibleVariant)) + return entry.getKey(); + } + return null; } + public Collection getAllVariants(Block block) { Map map = getVariants(block).variants; List blocks = new ArrayList<>(); diff --git a/src/main/java/org/violetmoon/quark/content/experimental/item/HammerItem.java b/src/main/java/org/violetmoon/quark/content/experimental/item/HammerItem.java index 9e5f5b46ef..b43b7d710b 100644 --- a/src/main/java/org/violetmoon/quark/content/experimental/item/HammerItem.java +++ b/src/main/java/org/violetmoon/quark/content/experimental/item/HammerItem.java @@ -39,7 +39,7 @@ public InteractionResult useOn(UseOnContext context) { if(player != null) { String variant = VariantSelectorModule.getSavedVariant(player); - Block variantBlock = VariantSelectorModule.getVariantOrOriginal(block, variant); + Block variantBlock = VariantSelectorModule.getVariantBlockFromAny(block, variant); if(variantBlock != null) { level.removeBlock(pos, false); diff --git a/src/main/java/org/violetmoon/quark/content/experimental/module/VariantSelectorModule.java b/src/main/java/org/violetmoon/quark/content/experimental/module/VariantSelectorModule.java index 07aaeaf7a9..219ebaf3ae 100644 --- a/src/main/java/org/violetmoon/quark/content/experimental/module/VariantSelectorModule.java +++ b/src/main/java/org/violetmoon/quark/content/experimental/module/VariantSelectorModule.java @@ -4,8 +4,8 @@ import java.util.Objects; import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.gui.Gui; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.lwjgl.glfw.GLFW; import org.lwjgl.opengl.GL11; import org.violetmoon.quark.base.Quark; @@ -42,7 +42,6 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.player.AbstractClientPlayer; -import net.minecraft.client.renderer.GameRenderer; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; @@ -57,12 +56,10 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; -import org.violetmoon.zetaimplforge.event.play.entity.player.ForgeZPlayer; @ZetaLoadModule( category = "experimental", enabledByDefault = false, @@ -102,6 +99,9 @@ public class VariantSelectorModule extends ZetaModule { @Config(description = "When true, selector arrow will render in same style as crosshair") public static boolean renderLikeCrossHair = true; + @Config(description = "Uses smaller arrow icon for variant selector overlay") + public static boolean smallerArrow = false; + @Config public static VariantsConfig variants = new VariantsConfig(); @@ -118,6 +118,7 @@ public final void configChanged(ZConfigChanged event) { staticEnabled = enabled; } + @NotNull public static String getSavedVariant(Player player) { if(player.level().isClientSide) return clientVariant; @@ -130,30 +131,31 @@ public static void setSavedVariant(ServerPlayer player, @NotNull String variant) player.getPersistentData().putString(TAG_CURRENT_VARIANT, variant); } + @Nullable private static Block getMainHandVariantBlock(Player player, String variant) { ItemStack mainHand = player.getMainHandItem(); if(mainHand.getItem() instanceof BlockItem blockItem) { Block block = blockItem.getBlock(); - return getVariantForBlock(block, variant); + return getVariantBlockFromOriginal(block, variant); } return null; } - public static Block getVariantForBlock(Block block, String variant) { - return variants.getBlockForVariant(block, variant); + // returns null if block was not changed! + // Like below but just accepts original block + @Nullable + public static Block getVariantBlockFromOriginal(Block original, @NotNull String variant) { + return variants.getBlockOfVariant(original, variant); } - public static Block getVariantOrOriginal(Block block, String variant) { - if(!variants.isVariant(block) && !variants.isOriginal(block)) - return null; - - block = variants.getOriginalBlock(block); - - if(variant == null || variant.isEmpty()) - return variants.getOriginalBlock(block); - - return getVariantForBlock(block, variant); + // returns null if block was not changed! + @Nullable + public static Block getVariantBlockFromAny(Block block, @NotNull String variant) { + Block originalBlock = variants.getOriginalBlock(block); + Block variantBlock = getVariantBlockFromOriginal(originalBlock, variant); + if(variantBlock != block)return variantBlock; + return null; } // Restore saved variant on join @@ -192,9 +194,11 @@ public static BlockState modifyBlockPlacementState(BlockState state, BlockPlaceC Player player = ctx.getPlayer(); if(player != null) { String variant = getSavedVariant(player); - if(variant != null && !variant.isEmpty()) { - Block target = getVariantForBlock(state.getBlock(), variant); - return target.getStateForPlacement(ctx); + if(!variant.isEmpty()) { + Block target = getVariantBlockFromOriginal(state.getBlock(), variant); + if (target != null) { + return target.getStateForPlacement(ctx); + } } } @@ -213,7 +217,7 @@ public static ItemStack modifyHeldItemStack(AbstractClientPlayer player, ItemSta if(player == mc.player && stack.getItem() instanceof BlockItem bi) { Block block = bi.getBlock(); if(!clientVariant.isEmpty()) { - Block variant = variants.getBlockForVariant(block, clientVariant); + Block variant = variants.getBlockOfVariant(block, clientVariant); if(variant != null && variant != block) return new ItemStack(variant); } @@ -235,13 +239,22 @@ public static void setClientVariant(String variant, boolean sync) { clientVariant = variant; } - public static boolean onPickBlock(Player player, ItemStack stack) { - ItemStack mainHand = player.getMainHandItem(); - if(mainHand.getItem() instanceof BlockItem handItem && stack.getItem() instanceof BlockItem variant) { - String variantKey = variants.getVariantForBlock(handItem.getBlock(), variant.getBlock()); - if(variantKey != null) { - setClientVariant(variantKey, true); - return true; + public static boolean onPickBlock(Player player, ItemStack pickResult) { + if(pickResult.getItem() instanceof BlockItem pickedVariant){ + Block pickedBlock = pickedVariant.getBlock(); + Block original = null; + ItemStack mainHand = player.getMainHandItem(); + if(mainHand.getItem() instanceof BlockItem handItem) { + original = handItem.getBlock(); + }else if(mainHand.is(hammer)){ + original = variants.getOriginalBlock(pickedBlock); + } + if(original!= null) { + String variantKey = variants.getVariantOfBlock(original, pickedBlock); + if (variantKey != null) { + setClientVariant(variantKey, true); + return true; + } } } return false; @@ -254,23 +267,31 @@ public void keystroke(ZInput.Key event) { if(variantSelectorKey.isDown()) { ItemStack stack = mc.player.getMainHandItem(); + Block originalBlock = null; if(stack.is(hammer)) { - HitResult result = mc.hitResult; - if(result instanceof BlockHitResult bhr) { - BlockPos pos = bhr.getBlockPos(); - Block block = mc.player.level().getBlockState(pos).getBlock(); - stack = new ItemStack(variants.getOriginalBlock(block)); - } + originalBlock = variants.getOriginalBlock(getLookedAtBlock()); + }else if(!stack.isEmpty() && stack.getItem() instanceof BlockItem bi){ + originalBlock = bi.getBlock(); + } + if(originalBlock != null){ + mc.setScreen(new VariantSelectorScreen(originalBlock, variantSelectorKey, + clientVariant, variants.getVisibleVariants())); } - - if(!stack.isEmpty() && stack.getItem() instanceof BlockItem) - mc.setScreen(new VariantSelectorScreen(stack, variantSelectorKey, clientVariant, variants.getVisibleVariants())); - - return; } } } + private Block getLookedAtBlock() { + Minecraft mc = Minecraft.getInstance(); + HitResult result = mc.hitResult; + if(result instanceof BlockHitResult bhr) { + BlockPos pos = bhr.getBlockPos(); + Block block = mc.player.level().getBlockState(pos).getBlock(); + return block; + } + return null; + } + @LoadEvent public void registerClientTooltipComponentFactories(ZTooltipComponents event) { event.register(VariantsComponent.class); @@ -310,84 +331,90 @@ public void onRender(ZRenderGuiOverlay.Crosshair.Pre event) { Player player = mc.player; String savedVariant = getSavedVariant(player); - if(savedVariant != null) { - ItemStack mainHand = player.getMainHandItem(); - ItemStack displayLeft = mainHand.copy(); + ItemStack mainHand = player.getMainHandItem(); + ItemStack displayLeft = mainHand.copy(); - Block variantBlock = null; + Block variantBlock = null; - if(displayLeft.is(hammer)) { - HitResult result = mc.hitResult; - if(result instanceof BlockHitResult bhr) { - BlockPos pos = bhr.getBlockPos(); - Block testBlock = player.level().getBlockState(pos).getBlock(); + if(displayLeft.is(hammer)) { + HitResult result = mc.hitResult; + if(result instanceof BlockHitResult bhr) { + BlockPos pos = bhr.getBlockPos(); + Block testBlock = player.level().getBlockState(pos).getBlock(); - displayLeft = new ItemStack(testBlock); - variantBlock = getVariantOrOriginal(testBlock, savedVariant); - } - } else - variantBlock = getMainHandVariantBlock(player, savedVariant); + displayLeft = new ItemStack(testBlock); + variantBlock = getVariantBlockFromAny(testBlock, savedVariant); + } + } else + variantBlock = getMainHandVariantBlock(player, savedVariant); - if(variantBlock != null) { - ItemStack displayRight = new ItemStack(variantBlock); + if(variantBlock != null) { + ItemStack displayRight = new ItemStack(variantBlock); - if(displayLeft.getItem() == displayRight.getItem()) - return; + if(displayLeft.getItem() == displayRight.getItem()) + return; - Window window = event.getWindow(); - int x = window.getGuiScaledWidth() / 2; - int y = window.getGuiScaledHeight() / 2 + 12; + Window window = event.getWindow(); + int x = window.getGuiScaledWidth() / 2; + int y = window.getGuiScaledHeight() / 2 + 12; - if(alignHudToHotbar) { - HumanoidArm arm = mc.options.mainHand().get(); - if(arm == HumanoidArm.RIGHT) - x += 125; - else - x -= 93; + if(alignHudToHotbar) { + HumanoidArm arm = mc.options.mainHand().get(); + if(arm == HumanoidArm.RIGHT) + x += 125; + else + x -= 93; - y = window.getGuiScaledHeight() - 19; - } + y = window.getGuiScaledHeight() - 19; + } - int offset = 8; - int width = 16; + int offset = 8; + int width = smallerArrow ? 13 : 16; - displayLeft.setCount(1); + displayLeft.setCount(1); - int posX = x - offset - width + hudOffsetX; - int posY = y + hudOffsetY; + int posX = x - offset - width + hudOffsetX; + int posY = y + hudOffsetY; - if( !showSimpleHud) { - guiGraphics.renderFakeItem(displayLeft, posX, posY); + if( !showSimpleHud) { + guiGraphics.renderFakeItem(displayLeft, posX, posY); - RenderSystem.enableBlend(); - if(renderLikeCrossHair) { - RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE_MINUS_DST_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1); - }else{ - RenderSystem.defaultBlendFunc(); - RenderSystem.setShaderColor(0.8f, 0.8f, 0.8f, 0.7f); - } - guiGraphics.blit(ClientUtil.GENERAL_ICONS, posX + 8, posY, 0, 141, 22, 15, 256, 256); + RenderSystem.enableBlend(); + if(renderLikeCrossHair) { + RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE_MINUS_DST_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1); + }else{ RenderSystem.defaultBlendFunc(); - - posX += width * 2; - } else { - final ResourceLocation WIDGETS_LOCATION = new ResourceLocation("textures/gui/widget.png"); - - if(alignHudToHotbar) { - RenderSystem.enableBlend(); - RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - if(enableGreenTint) - RenderSystem.setShaderColor(0.5F, 1.0F, 0.5F, 1.0F); - else - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - guiGraphics.blit(WIDGETS_LOCATION, posX - 3, posY - 3, 24, 23, 22, 22, 256, 256); - } else - posX += width; + RenderSystem.setShaderColor(0.8f, 0.8f, 0.8f, 0.7f); } + //alternative smaller arrow + if(smallerArrow){ + guiGraphics.blit(ClientUtil.GENERAL_ICONS, posX + 8, posY+5, 0, + 141+17, 22, 15, 256, 256); + }else { + guiGraphics.blit(ClientUtil.GENERAL_ICONS, posX + 8, posY, 0, + 141, 22, 15, 256, 256); + } + + RenderSystem.defaultBlendFunc(); - guiGraphics.renderFakeItem(displayRight, posX, posY); + posX += width * 2; + } else { + final ResourceLocation WIDGETS_LOCATION = new ResourceLocation("textures/gui/widget.png"); + + if(alignHudToHotbar) { + RenderSystem.enableBlend(); + RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + if(enableGreenTint) + RenderSystem.setShaderColor(0.5F, 1.0F, 0.5F, 1.0F); + else + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + guiGraphics.blit(WIDGETS_LOCATION, posX - 3, posY - 3, 24, 23, 22, 22, 256, 256); + } else + posX += width; } + + guiGraphics.renderFakeItem(displayRight, posX, posY); } } } diff --git a/src/main/resources/assets/quark/lang/en_us.json b/src/main/resources/assets/quark/lang/en_us.json index 211ff28fa7..8fd939c480 100644 --- a/src/main/resources/assets/quark/lang/en_us.json +++ b/src/main/resources/assets/quark/lang/en_us.json @@ -518,7 +518,6 @@ "item.quark.moss_paste": "Moss Paste", "item.quark.backpack": "Backpack", "item.quark.ravager_hide": "Ravager Hide", - "item.quark.soul_compass": "Soul Compass", "item.quark.bottled_cloud": "Cloud in a Bottle", "item.quark.flamerang": "Flamarang", "item.quark.seed_pouch": "Seed Pouch", diff --git a/src/main/resources/assets/quark/textures/gui/general_icons.png b/src/main/resources/assets/quark/textures/gui/general_icons.png index 65cee3d330..875bcc5e1f 100644 Binary files a/src/main/resources/assets/quark/textures/gui/general_icons.png and b/src/main/resources/assets/quark/textures/gui/general_icons.png differ