mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 05:08: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;
|
package de.ellpeck.naturesaura.events;
|
||||||
|
|
||||||
import baubles.api.BaubleType;
|
|
||||||
import baubles.api.BaublesApi;
|
import baubles.api.BaublesApi;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
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.common.gameevent.TickEvent.ClientTickEvent;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import org.apache.commons.lang3.mutable.MutableInt;
|
import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -90,105 +90,113 @@ public class ClientEvents {
|
||||||
if (event.getType() == ElementType.ALL) {
|
if (event.getType() == ElementType.ALL) {
|
||||||
ScaledResolution res = event.getResolution();
|
ScaledResolution res = event.getResolution();
|
||||||
if (mc.player != null) {
|
if (mc.player != null) {
|
||||||
ItemStack stack = mc.player.getHeldItemMainhand();
|
ItemStack cache = ItemStack.EMPTY;
|
||||||
if (mc.currentScreen == null) {
|
ItemStack eye = ItemStack.EMPTY;
|
||||||
if (!stack.isEmpty() && stack.getItem() == ModItems.EYE || Compat.baubles && BaublesApi.isBaubleEquipped(mc.player, ModItems.EYE) >= 0) {
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
|
||||||
|
|
||||||
GlStateManager.color(0.8F, 0.25F, 0.25F);
|
if (Compat.baubles) {
|
||||||
float totalPercentage = AuraChunk.getAuraInArea(mc.world, mc.player.getPosition(), 15) / (AuraChunk.DEFAULT_AURA * 2F);
|
IItemHandler baubles = BaublesApi.getBaublesHandler(mc.player);
|
||||||
int tHeight = MathHelper.ceil(MathHelper.clamp(totalPercentage, 0F, 1F) * 50);
|
for (int i = 0; i < baubles.getSlots(); i++) {
|
||||||
if (tHeight < 50)
|
ItemStack slot = baubles.getStackInSlot(i);
|
||||||
Gui.drawModalRectWithCustomSizedTexture(3, 10, 6, 12, 6, 50 - tHeight, 256, 256);
|
if (!slot.isEmpty()) {
|
||||||
if (tHeight > 0)
|
if (slot.getItem() == ModItems.AURA_CACHE) {
|
||||||
Gui.drawModalRectWithCustomSizedTexture(3, 10 + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256);
|
cache = slot;
|
||||||
|
break;
|
||||||
|
} else if (slot.getItem() == ModItems.EYE) {
|
||||||
|
eye = slot;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mc.objectMouseOver != null) {
|
if (cache.isEmpty() || eye.isEmpty()) {
|
||||||
BlockPos pos = mc.objectMouseOver.getBlockPos();
|
for (int i = 0; i < mc.player.inventory.getSizeInventory(); i++) {
|
||||||
if (pos != null) {
|
ItemStack slot = mc.player.inventory.getStackInSlot(i);
|
||||||
TileEntity tile = mc.world.getTileEntity(pos);
|
if (!slot.isEmpty()) {
|
||||||
if (tile != null && tile.hasCapability(Capabilities.auraContainer, null)) {
|
if (slot.getItem() == ModItems.AURA_CACHE) {
|
||||||
IAuraContainer container = tile.getCapability(Capabilities.auraContainer, null);
|
cache = slot;
|
||||||
|
break;
|
||||||
|
} else if (slot.getItem() == ModItems.EYE && i <= 8) {
|
||||||
|
eye = slot;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IBlockState state = mc.world.getBlockState(pos);
|
if (!cache.isEmpty()) {
|
||||||
ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player);
|
IAuraContainer container = cache.getCapability(Capabilities.auraContainer, null);
|
||||||
this.drawContainerInfo(container, mc, res, 25, blockStack.getDisplayName());
|
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;
|
||||||
|
|
||||||
if (tile instanceof TileEntityNatureAltar) {
|
GlStateManager.pushMatrix();
|
||||||
ItemStack tileStack = ((TileEntityNatureAltar) tile).getItemHandler(null).getStackInSlot(0);
|
|
||||||
if (!tileStack.isEmpty() && tileStack.hasCapability(Capabilities.auraContainer, null)) {
|
int color = container.getAuraColor();
|
||||||
IAuraContainer stackContainer = tileStack.getCapability(Capabilities.auraContainer, null);
|
GlStateManager.color((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
||||||
this.drawContainerInfo(stackContainer, mc, res, 45, tileStack.getDisplayName());
|
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);
|
||||||
|
|
||||||
|
GlStateManager.color(0.8F, 0.25F, 0.25F);
|
||||||
|
float totalPercentage = AuraChunk.getAuraInArea(mc.world, mc.player.getPosition(), 15) / (AuraChunk.DEFAULT_AURA * 2F);
|
||||||
|
int tHeight = MathHelper.ceil(MathHelper.clamp(totalPercentage, 0F, 1F) * 50);
|
||||||
|
if (tHeight < 50)
|
||||||
|
Gui.drawModalRectWithCustomSizedTexture(3, 10, 6, 12, 6, 50 - tHeight, 256, 256);
|
||||||
|
if (tHeight > 0)
|
||||||
|
Gui.drawModalRectWithCustomSizedTexture(3, 10 + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256);
|
||||||
|
|
||||||
|
if (mc.objectMouseOver != null) {
|
||||||
|
BlockPos pos = mc.objectMouseOver.getBlockPos();
|
||||||
|
if (pos != null) {
|
||||||
|
TileEntity tile = mc.world.getTileEntity(pos);
|
||||||
|
if (tile != null && tile.hasCapability(Capabilities.auraContainer, null)) {
|
||||||
|
IAuraContainer container = tile.getCapability(Capabilities.auraContainer, null);
|
||||||
|
|
||||||
|
IBlockState state = mc.world.getBlockState(pos);
|
||||||
|
ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player);
|
||||||
|
this.drawContainerInfo(container, mc, res, 25, blockStack.getDisplayName());
|
||||||
|
|
||||||
|
if (tile instanceof TileEntityNatureAltar) {
|
||||||
|
ItemStack tileStack = ((TileEntityNatureAltar) tile).getItemHandler(null).getStackInSlot(0);
|
||||||
|
if (!tileStack.isEmpty() && tileStack.hasCapability(Capabilities.auraContainer, null)) {
|
||||||
|
IAuraContainer stackContainer = tileStack.getCapability(Capabilities.auraContainer, null);
|
||||||
|
this.drawContainerInfo(stackContainer, mc, res, 45, tileStack.getDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalPercentage > 1F)
|
|
||||||
mc.fontRenderer.drawString("+", 10F, 9.5F, 0xBB3333, true);
|
|
||||||
if (totalPercentage < 0F)
|
|
||||||
mc.fontRenderer.drawString("-", 10F, 53.5F, 0xBB3333, true);
|
|
||||||
|
|
||||||
float scale = 0.75F;
|
|
||||||
GlStateManager.scale(scale, scale, scale);
|
|
||||||
mc.fontRenderer.drawString(I18n.format("info." + NaturesAura.MOD_ID + ".aura_in_area"), 3 / scale, 3 / scale, 0xBB3333, true);
|
|
||||||
|
|
||||||
GlStateManager.color(1F, 1F, 1F);
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.displayAuraCache(mc, res);
|
if (totalPercentage > 1F)
|
||||||
}
|
mc.fontRenderer.drawString("+", 10F, 9.5F, 0xBB3333, true);
|
||||||
}
|
if (totalPercentage < 0F)
|
||||||
}
|
mc.fontRenderer.drawString("-", 10F, 53.5F, 0xBB3333, true);
|
||||||
|
|
||||||
private void displayAuraCache(Minecraft mc, ScaledResolution res) {
|
float scale = 0.75F;
|
||||||
ItemStack stack = ItemStack.EMPTY;
|
GlStateManager.scale(scale, scale, scale);
|
||||||
|
mc.fontRenderer.drawString(I18n.format("info." + NaturesAura.MOD_ID + ".aura_in_area"), 3 / scale, 3 / scale, 0xBB3333, true);
|
||||||
|
|
||||||
if (Compat.baubles) {
|
GlStateManager.color(1F, 1F, 1F);
|
||||||
ItemStack slot = BaublesApi.getBaublesHandler(mc.player).getStackInSlot(BaubleType.BELT.getValidSlots()[0]);
|
GlStateManager.popMatrix();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawContainerInfo(IAuraContainer container, Minecraft mc, ScaledResolution res, int yOffset, String name) {
|
private void drawContainerInfo(IAuraContainer container, Minecraft mc, ScaledResolution res, int yOffset, String name) {
|
||||||
|
|
|
@ -97,10 +97,11 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void render(ItemStack stack, EntityPlayer player, RenderType type) {
|
public void render(ItemStack stack, EntityPlayer player, RenderType type, boolean isHolding) {
|
||||||
if (type == RenderType.BODY) {
|
if (type == RenderType.BODY && !isHolding) {
|
||||||
boolean armor = !player.inventory.armorInventory.get(EntityEquipmentSlot.CHEST.getIndex()).isEmpty();
|
boolean chest = !player.inventory.armorInventory.get(EntityEquipmentSlot.CHEST.getIndex()).isEmpty();
|
||||||
GlStateManager.translate(-0.15F, 0.65F, armor ? -0.195F : -0.13F);
|
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.scale(0.25F, 0.25F, 0.25F);
|
||||||
GlStateManager.rotate(180F, 1F, 0F, 0F);
|
GlStateManager.rotate(180F, 1F, 0F, 0F);
|
||||||
Helper.renderItemInWorld(stack);
|
Helper.renderItemInWorld(stack);
|
||||||
|
|
|
@ -19,8 +19,8 @@ public class ItemEye extends ItemImpl implements ITrinketItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void render(ItemStack stack, EntityPlayer player, RenderType type) {
|
public void render(ItemStack stack, EntityPlayer player, RenderType type, boolean isHolding) {
|
||||||
if (type == RenderType.BODY) {
|
if (type == RenderType.BODY && !isHolding) {
|
||||||
boolean armor = !player.inventory.armorInventory.get(EntityEquipmentSlot.CHEST.getIndex()).isEmpty();
|
boolean armor = !player.inventory.armorInventory.get(EntityEquipmentSlot.CHEST.getIndex()).isEmpty();
|
||||||
GlStateManager.translate(0.1F, 0.19F, armor ? -0.195F : -0.13F);
|
GlStateManager.translate(0.1F, 0.19F, armor ? -0.195F : -0.13F);
|
||||||
GlStateManager.scale(0.15F, 0.15F, 0.15F);
|
GlStateManager.scale(0.15F, 0.15F, 0.15F);
|
||||||
|
|
|
@ -9,5 +9,5 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
public interface ITrinketItem {
|
public interface ITrinketItem {
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@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) {
|
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)
|
if (player.getActivePotionEffect(MobEffects.INVISIBILITY) != null)
|
||||||
return;
|
return;
|
||||||
|
ItemStack main = player.getHeldItemMainhand();
|
||||||
|
ItemStack second = player.getHeldItemOffhand();
|
||||||
|
|
||||||
this.alreadyRendered.clear();
|
this.alreadyRendered.clear();
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.color(1F, 1F, 1F, 1F);
|
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 yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks;
|
||||||
float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks;
|
float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks;
|
||||||
float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks;
|
float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks;
|
||||||
GlStateManager.rotate(yawOffset, 0, -1, 0);
|
GlStateManager.rotate(yawOffset, 0, -1, 0);
|
||||||
GlStateManager.rotate(yaw - 270, 0, 1, 0);
|
GlStateManager.rotate(yaw - 270, 0, 1, 0);
|
||||||
GlStateManager.rotate(pitch, 0, 0, 1);
|
GlStateManager.rotate(pitch, 0, 0, 1);
|
||||||
this.render(player, RenderType.HEAD);
|
this.render(player, RenderType.HEAD, main, second);
|
||||||
GlStateManager.popMatrix();
|
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++) {
|
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) {
|
if (Compat.baubles) {
|
||||||
IItemHandler baubles = BaublesApi.getBaublesHandler(player);
|
IItemHandler baubles = BaublesApi.getBaublesHandler(player);
|
||||||
for (int i = 0; i < baubles.getSlots(); i++) {
|
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()) {
|
if (!stack.isEmpty()) {
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if (item instanceof ITrinketItem && !this.alreadyRendered.contains(item)) {
|
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.translate(0F, 0.2F, 0F);
|
||||||
GlStateManager.rotate(90F / (float) Math.PI, 1.0F, 0.0F, 0.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();
|
GlStateManager.popMatrix();
|
||||||
this.alreadyRendered.add(item);
|
this.alreadyRendered.add(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"pages": [
|
"pages": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"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",
|
"type": "text",
|
||||||
|
|
Loading…
Reference in a new issue