mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-25 20:58:34 +01:00
made the eye work anywhere in the hotbar and fixed some minor visual issues with player rendering
This commit is contained in:
parent
4626d90c00
commit
7f13f59ccf
6 changed files with 111 additions and 100 deletions
|
@ -1,6 +1,5 @@
|
|||
package de.ellpeck.naturesaura.events;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.BaublesApi;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
||||
|
@ -31,6 +30,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|||
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -90,9 +90,66 @@ public class ClientEvents {
|
|||
if (event.getType() == ElementType.ALL) {
|
||||
ScaledResolution res = event.getResolution();
|
||||
if (mc.player != null) {
|
||||
ItemStack stack = mc.player.getHeldItemMainhand();
|
||||
if (mc.currentScreen == null) {
|
||||
if (!stack.isEmpty() && stack.getItem() == ModItems.EYE || Compat.baubles && BaublesApi.isBaubleEquipped(mc.player, ModItems.EYE) >= 0) {
|
||||
ItemStack cache = ItemStack.EMPTY;
|
||||
ItemStack eye = ItemStack.EMPTY;
|
||||
|
||||
if (Compat.baubles) {
|
||||
IItemHandler baubles = BaublesApi.getBaublesHandler(mc.player);
|
||||
for (int i = 0; i < baubles.getSlots(); i++) {
|
||||
ItemStack slot = baubles.getStackInSlot(i);
|
||||
if (!slot.isEmpty()) {
|
||||
if (slot.getItem() == ModItems.AURA_CACHE) {
|
||||
cache = slot;
|
||||
break;
|
||||
} else if (slot.getItem() == ModItems.EYE) {
|
||||
eye = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cache.isEmpty() || eye.isEmpty()) {
|
||||
for (int i = 0; i < mc.player.inventory.getSizeInventory(); i++) {
|
||||
ItemStack slot = mc.player.inventory.getStackInSlot(i);
|
||||
if (!slot.isEmpty()) {
|
||||
if (slot.getItem() == ModItems.AURA_CACHE) {
|
||||
cache = slot;
|
||||
break;
|
||||
} else if (slot.getItem() == ModItems.EYE && i <= 8) {
|
||||
eye = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!cache.isEmpty()) {
|
||||
IAuraContainer container = cache.getCapability(Capabilities.auraContainer, null);
|
||||
int width = MathHelper.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
|
||||
int x = res.getScaledWidth() / 2 - 173 - (mc.player.getHeldItemOffhand().isEmpty() ? 0 : 29);
|
||||
int y = res.getScaledHeight() - 8;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
int color = container.getAuraColor();
|
||||
GlStateManager.color((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
||||
if (width < 80)
|
||||
Gui.drawModalRectWithCustomSizedTexture(x + width, y, width, 0, 80 - width, 6, 256, 256);
|
||||
if (width > 0)
|
||||
Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 6, width, 6, 256, 256);
|
||||
|
||||
float scale = 0.75F;
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
String s = cache.getDisplayName();
|
||||
mc.fontRenderer.drawString(s, (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color, true);
|
||||
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
if (!eye.isEmpty()) {
|
||||
GlStateManager.pushMatrix();
|
||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
||||
|
||||
|
@ -139,55 +196,6 @@ public class ClientEvents {
|
|||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
this.displayAuraCache(mc, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void displayAuraCache(Minecraft mc, ScaledResolution res) {
|
||||
ItemStack stack = ItemStack.EMPTY;
|
||||
|
||||
if (Compat.baubles) {
|
||||
ItemStack slot = BaublesApi.getBaublesHandler(mc.player).getStackInSlot(BaubleType.BELT.getValidSlots()[0]);
|
||||
if (!slot.isEmpty() && slot.getItem() == ModItems.AURA_CACHE) {
|
||||
stack = slot;
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.isEmpty()) {
|
||||
for (int i = 0; i < mc.player.inventory.getSizeInventory(); i++) {
|
||||
ItemStack slot = mc.player.inventory.getStackInSlot(i);
|
||||
if (!slot.isEmpty() && slot.getItem() == ModItems.AURA_CACHE) {
|
||||
stack = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!stack.isEmpty()) {
|
||||
IAuraContainer container = stack.getCapability(Capabilities.auraContainer, null);
|
||||
int width = MathHelper.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
|
||||
int x = res.getScaledWidth() / 2 - 173 - (mc.player.getHeldItemOffhand().isEmpty() ? 0 : 29);
|
||||
int y = res.getScaledHeight() - 8;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
int color = container.getAuraColor();
|
||||
GlStateManager.color((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
||||
if (width < 80)
|
||||
Gui.drawModalRectWithCustomSizedTexture(x + width, y, width, 0, 80 - width, 6, 256, 256);
|
||||
if (width > 0)
|
||||
Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 6, width, 6, 256, 256);
|
||||
|
||||
float scale = 0.75F;
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
String s = stack.getDisplayName();
|
||||
mc.fontRenderer.drawString(s, (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color, true);
|
||||
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,10 +97,11 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(ItemStack stack, EntityPlayer player, RenderType type) {
|
||||
if (type == RenderType.BODY) {
|
||||
boolean armor = !player.inventory.armorInventory.get(EntityEquipmentSlot.CHEST.getIndex()).isEmpty();
|
||||
GlStateManager.translate(-0.15F, 0.65F, armor ? -0.195F : -0.13F);
|
||||
public void render(ItemStack stack, EntityPlayer player, RenderType type, boolean isHolding) {
|
||||
if (type == RenderType.BODY && !isHolding) {
|
||||
boolean chest = !player.inventory.armorInventory.get(EntityEquipmentSlot.CHEST.getIndex()).isEmpty();
|
||||
boolean legs = !player.inventory.armorInventory.get(EntityEquipmentSlot.LEGS.getIndex()).isEmpty();
|
||||
GlStateManager.translate(-0.15F, 0.65F, chest ? -0.195F : (legs ? -0.165F : -0.13F));
|
||||
GlStateManager.scale(0.25F, 0.25F, 0.25F);
|
||||
GlStateManager.rotate(180F, 1F, 0F, 0F);
|
||||
Helper.renderItemInWorld(stack);
|
||||
|
|
|
@ -19,8 +19,8 @@ public class ItemEye extends ItemImpl implements ITrinketItem {
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void render(ItemStack stack, EntityPlayer player, RenderType type) {
|
||||
if (type == RenderType.BODY) {
|
||||
public void render(ItemStack stack, EntityPlayer player, RenderType type, boolean isHolding) {
|
||||
if (type == RenderType.BODY && !isHolding) {
|
||||
boolean armor = !player.inventory.armorInventory.get(EntityEquipmentSlot.CHEST.getIndex()).isEmpty();
|
||||
GlStateManager.translate(0.1F, 0.19F, armor ? -0.195F : -0.13F);
|
||||
GlStateManager.scale(0.15F, 0.15F, 0.15F);
|
||||
|
|
|
@ -9,5 +9,5 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
public interface ITrinketItem {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void render(ItemStack stack, EntityPlayer player, RenderType type);
|
||||
void render(ItemStack stack, EntityPlayer player, RenderType type, boolean isHolding);
|
||||
}
|
||||
|
|
|
@ -25,36 +25,38 @@ public class PlayerLayerTrinkets implements LayerRenderer<EntityPlayer> {
|
|||
public void doRenderLayer(@Nonnull EntityPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
|
||||
if (player.getActivePotionEffect(MobEffects.INVISIBILITY) != null)
|
||||
return;
|
||||
ItemStack main = player.getHeldItemMainhand();
|
||||
ItemStack second = player.getHeldItemOffhand();
|
||||
|
||||
this.alreadyRendered.clear();
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.color(1F, 1F, 1F, 1F);
|
||||
this.render(player, RenderType.BODY);
|
||||
this.render(player, RenderType.BODY, main, second);
|
||||
float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks;
|
||||
float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks;
|
||||
float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks;
|
||||
GlStateManager.rotate(yawOffset, 0, -1, 0);
|
||||
GlStateManager.rotate(yaw - 270, 0, 1, 0);
|
||||
GlStateManager.rotate(pitch, 0, 0, 1);
|
||||
this.render(player, RenderType.HEAD);
|
||||
this.render(player, RenderType.HEAD, main, second);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
}
|
||||
|
||||
private void render(EntityPlayer player, RenderType type) {
|
||||
private void render(EntityPlayer player, RenderType type, ItemStack main, ItemStack second) {
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||
this.renderStack(player.inventory.getStackInSlot(i), player, type);
|
||||
this.renderStack(player.inventory.getStackInSlot(i), player, type, main, second);
|
||||
}
|
||||
|
||||
if (Compat.baubles) {
|
||||
IItemHandler baubles = BaublesApi.getBaublesHandler(player);
|
||||
for (int i = 0; i < baubles.getSlots(); i++) {
|
||||
this.renderStack(baubles.getStackInSlot(i), player, type);
|
||||
this.renderStack(baubles.getStackInSlot(i), player, type, main, second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderStack(ItemStack stack, EntityPlayer player, RenderType type) {
|
||||
private void renderStack(ItemStack stack, EntityPlayer player, RenderType type, ItemStack main, ItemStack second) {
|
||||
if (!stack.isEmpty()) {
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof ITrinketItem && !this.alreadyRendered.contains(item)) {
|
||||
|
@ -63,7 +65,7 @@ public class PlayerLayerTrinkets implements LayerRenderer<EntityPlayer> {
|
|||
GlStateManager.translate(0F, 0.2F, 0F);
|
||||
GlStateManager.rotate(90F / (float) Math.PI, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
((ITrinketItem) item).render(stack, player, type);
|
||||
((ITrinketItem) item).render(stack, player, type, stack == main || stack == second);
|
||||
GlStateManager.popMatrix();
|
||||
this.alreadyRendered.add(item);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"pages": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "When working with $(aura), by nature, it will be hard to grasp just how much there is in any given area or storage device. The $(item)Environmental Eye$() has the powers to display this information to botanists though: Once created, merely holding it in your hand will display several pieces of information:"
|
||||
"text": "When working with $(aura), by nature, it will be hard to grasp just how much there is in any given area or storage device. The $(item)Environmental Eye$() has the powers to display this information to botanists though: Once created, merely holding it anywhere in one's hotbar will display several pieces of information:"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
|
|
Loading…
Reference in a new issue