Skip to content

Commit

Permalink
You can now place blocks on top of the bones flying around you. Added…
Browse files Browse the repository at this point in the history
… ability to see enchants from the enchant table without hovering over the item.
  • Loading branch information
biscuut committed Jul 3, 2019
1 parent 9ff3afa commit 5884bce
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
version = "1.0-b1"
version = "1.0-b3"
group= "codes.biscuit.skyblockaddons" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "SkyblockAddons"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class SkyblockAddons {

static final String MOD_ID = "skyblockaddons";
static final String MOD_NAME = "SkyblockAddons";
static final String VERSION = "1.0";
static final String VERSION = "1.0-b3";

public static SkyblockAddons INSTANCE; // for Mixins cause they don't have a constructor
private ConfigValues configValues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ public void onRenderManaBar(RenderGameOverlayEvent.Post e) {
int bones = 0;
for (Entity listEntity : mc.theWorld.loadedEntityList) {
if (listEntity instanceof EntityItem &&
listEntity.ridingEntity instanceof EntityZombie && listEntity.ridingEntity.isInvisible()) {
listEntity.ridingEntity instanceof EntityZombie && listEntity.ridingEntity.isInvisible() && listEntity.getDistanceToEntity(mc.thePlayer) <= 6) {
bones++;
}
}
if (bones > 3) bones = 3;
for (int boneCounter = 0; boneCounter < bones; boneCounter++) {
mc.getRenderItem().renderItemIntoGUI(BONE, width+(boneCounter*15), height);
mc.getRenderItem().renderItemIntoGUI(BONE, width+(boneCounter*15)+2, height+2);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MixinEntityRenderer {

@Inject(method = "getMouseOver", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 0), locals = LocalCapture.CAPTURE_FAILSOFT)
private void intersectsWith(float partialTicks, CallbackInfo ci, Entity entity, double d0, double d1, Vec3 vec3, boolean flag, boolean b, Vec3 vec31, Vec3 vec32, Vec3 vec33, float f, List<Entity> list, double d2, int i) {
if (Utils.isOnSkyblock()) {
if (Utils.isOnSkyblock()) { // conditions for the invisible zombie that Skeleton hat bones are riding
list.removeIf(listEntity -> listEntity instanceof EntityZombie && listEntity.isInvisible() && listEntity.riddenByEntity instanceof EntityItem);
}
}
Expand Down
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();
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ public abstract class MixinRenderManager {

@Inject(method = "shouldRender", at = @At(value = "HEAD"), cancellable = true)
private void shouldRenderRedirect(Entity entityIn, ICamera camera, double camX, double camY, double camZ, CallbackInfoReturnable<Boolean> cir) {
if (!SkyblockAddons.INSTANCE.getConfigValues().getDisabledFeatures().contains(Feature.BONES) && entityIn instanceof EntityItem &&
entityIn.ridingEntity instanceof EntityZombie && entityIn.ridingEntity.isInvisible()) {
cir.setReturnValue(false);
if (entityIn instanceof EntityItem &&
entityIn.ridingEntity instanceof EntityZombie && entityIn.ridingEntity.isInvisible()) { // Conditions for Skeleton Hat flying bones
entityIn.ridingEntity.preventEntitySpawning = false; // To allow you to place blocks
if (!SkyblockAddons.INSTANCE.getConfigValues().getDisabledFeatures().contains(Feature.BONES)) {
cir.setReturnValue(false);
}
}
}
}
27 changes: 27 additions & 0 deletions src/main/java/codes/biscuit/skyblockaddons/utils/EnchantPair.java
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;
}
}
3 changes: 1 addition & 2 deletions src/main/java/codes/biscuit/skyblockaddons/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.common.MinecraftForge;

import java.util.Collection;
import java.util.List;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/mixins.skyblockaddons.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"MixinEntityPlayerSP",
"MixinSoundManager",
"MixinEntityRenderer",
"MixinRenderManager"
"MixinRenderManager",
"MixinGuiContainer"
]
}

0 comments on commit 5884bce

Please sign in to comment.