-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
You can now place blocks on top of the bones flying around you. Added…
… ability to see enchants from the enchant table without hovering over the item.
- Loading branch information
Showing
9 changed files
with
113 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/codes/biscuit/skyblockaddons/mixins/MixinGuiContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package codes.biscuit.skyblockaddons.mixins; | ||
|
||
import codes.biscuit.skyblockaddons.utils.EnchantPair; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.FontRenderer; | ||
import net.minecraft.client.gui.inventory.GuiContainer; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.inventory.Slot; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.EnumChatFormatting; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
import java.awt.*; | ||
import java.util.HashSet; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.regex.Pattern; | ||
|
||
@Mixin(GuiContainer.class) | ||
public class MixinGuiContainer { | ||
|
||
private Set<EnchantPair> enchantsToRender = new HashSet<>(); | ||
|
||
@Inject(method = "drawSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderItemOverlayIntoGUI(Lnet/minecraft/client/gui/FontRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", | ||
ordinal = 0), locals = LocalCapture.CAPTURE_FAILSOFT) | ||
private void shouldRenderSaveSlots(Slot slotIn, CallbackInfo ci, int i, int j, ItemStack item, boolean flag, boolean flag1, | ||
ItemStack itemstack1, String s) { | ||
Minecraft mc = Minecraft.getMinecraft(); | ||
FontRenderer fr = mc.fontRendererObj; | ||
if (item != null && item.hasDisplayName() && item.getDisplayName().startsWith(EnumChatFormatting.GREEN+"Enchant Item")) { | ||
List<String> toolip = item.getTooltip(mc.thePlayer, false); | ||
if (toolip.size() > 2) { | ||
String enchantLine = toolip.get(2); | ||
String enchant = EnumChatFormatting.YELLOW + enchantLine.split(Pattern.quote("* "))[1]; | ||
float y; | ||
if (slotIn.slotNumber == 29 || slotIn.slotNumber == 33) { | ||
y = 26; | ||
} else { | ||
y = 36; | ||
} | ||
float scaleMultiplier = 1 / 0.75F; | ||
float halfStringWidth = fr.getStringWidth(enchant) / 2; | ||
i += 8; // to center it | ||
enchantsToRender.add(new EnchantPair(i * scaleMultiplier - halfStringWidth, j * scaleMultiplier + y, enchant)); | ||
} | ||
} | ||
if (slotIn.slotNumber == 53) { | ||
Iterator<EnchantPair> enchantPairIterator = enchantsToRender.iterator(); | ||
while (enchantPairIterator.hasNext()) { | ||
EnchantPair enchant = enchantPairIterator.next(); | ||
GlStateManager.pushMatrix(); | ||
GlStateManager.scale(0.75, 0.75, 1); | ||
|
||
GlStateManager.disableLighting(); | ||
GlStateManager.disableDepth(); | ||
GlStateManager.disableBlend(); | ||
fr.drawStringWithShadow(enchant.getEnchant(), enchant.getX(), enchant.getY(), new Color(255,255,255,255).getRGB()); | ||
GlStateManager.enableLighting(); | ||
GlStateManager.enableDepth(); | ||
|
||
GlStateManager.popMatrix(); | ||
enchantPairIterator.remove(); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/codes/biscuit/skyblockaddons/utils/EnchantPair.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package codes.biscuit.skyblockaddons.utils; | ||
|
||
public class EnchantPair { | ||
|
||
private float x; | ||
private float y; | ||
private String enchant; | ||
|
||
|
||
public EnchantPair(float x, float y, String enchant) { | ||
this.x = x; | ||
this.y = y; | ||
this.enchant = enchant; | ||
} | ||
|
||
public float getX() { | ||
return x; | ||
} | ||
|
||
public float getY() { | ||
return y; | ||
} | ||
|
||
public String getEnchant() { | ||
return enchant; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters