mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-26 08:19:24 +01:00
fixed all the rendering yeees
This commit is contained in:
parent
161e38187e
commit
e8e3457b34
6 changed files with 99 additions and 82 deletions
|
@ -1,5 +1,7 @@
|
|||
package de.ellpeck.naturesaura.api.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -11,6 +13,6 @@ public interface ITrinketItem {
|
|||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
void render(ItemStack stack, PlayerEntity player, RenderType type, boolean isHolding);
|
||||
void render(ItemStack stack, PlayerEntity player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package de.ellpeck.naturesaura.compat.jei;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
|
@ -11,9 +13,14 @@ import mezz.jei.api.helpers.IGuiHelper;
|
|||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
|
@ -85,31 +92,48 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
|
|||
}
|
||||
|
||||
float size = Math.max(1F, Math.max(recipe.entity.getWidth(), recipe.entity.getHeight()));
|
||||
float rot = (minecraft.world.getGameTime() + minecraft.getRenderPartialTicks()) % 360F;
|
||||
renderEntity(entity, 35, 28, rot, 100F / size * 0.4F, size * 0.5F);
|
||||
renderEntity(35, 55, 100F / size * 0.4F, 40, size * 0.5F, (LivingEntity) entity);
|
||||
|
||||
String name = recipe.entity.getName().getFormattedText();
|
||||
minecraft.fontRenderer.drawStringWithShadow(name, 36 - minecraft.fontRenderer.getStringWidth(name) / 2F, 55, 0xFFFFFF);
|
||||
}
|
||||
|
||||
private static void renderEntity(Entity entity, float x, float y, float rotation, float renderScale, float offset) {
|
||||
// TODO Render entity
|
||||
/*GlStateManager.enableColorMaterial();
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.color3f(1F, 1F, 1F);
|
||||
GlStateManager.translatef(x, y, 50.0F);
|
||||
GlStateManager.scalef(-renderScale, renderScale, renderScale);
|
||||
GlStateManager.translatef(0F, offset, 0F);
|
||||
GlStateManager.rotatef(180.0F, 0.0F, 0.0F, 1.0F);
|
||||
GlStateManager.rotatef(rotation, 0.0F, 1.0F, 0.0F);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
Minecraft.getInstance().getRenderManager().playerViewY = 180.0F;
|
||||
Minecraft.getInstance().getRenderManager().renderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
|
||||
GlStateManager.popMatrix();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.disableRescaleNormal();
|
||||
GlStateManager.activeTexture(GLX.GL_TEXTURE1);
|
||||
GlStateManager.disableTexture();
|
||||
GlStateManager.activeTexture(GLX.GL_TEXTURE0);*/
|
||||
private static void renderEntity(int x, int y, float scale, float yaw, float pitch, LivingEntity entity) {
|
||||
float f = (float) Math.atan(yaw / 40.0F);
|
||||
float f1 = (float) Math.atan(pitch / 40.0F);
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translatef((float) x, (float) y, 1050.0F);
|
||||
RenderSystem.scalef(1.0F, 1.0F, -1.0F);
|
||||
MatrixStack matrixstack = new MatrixStack();
|
||||
matrixstack.translate(0.0D, 0.0D, 1000.0D);
|
||||
matrixstack.scale(scale, scale, scale);
|
||||
Quaternion quaternion = Vector3f.ZP.rotationDegrees(180.0F);
|
||||
Quaternion quaternion1 = Vector3f.XP.rotationDegrees(f1 * 20.0F);
|
||||
quaternion.multiply(quaternion1);
|
||||
matrixstack.rotate(quaternion);
|
||||
float f2 = entity.renderYawOffset;
|
||||
float f3 = entity.rotationYaw;
|
||||
float f4 = entity.rotationPitch;
|
||||
float f5 = entity.prevRotationYawHead;
|
||||
float f6 = entity.rotationYawHead;
|
||||
entity.renderYawOffset = 180.0F + f * 20.0F;
|
||||
entity.rotationYaw = 180.0F + f * 40.0F;
|
||||
entity.rotationPitch = -f1 * 20.0F;
|
||||
entity.rotationYawHead = entity.rotationYaw;
|
||||
entity.prevRotationYawHead = entity.rotationYaw;
|
||||
EntityRendererManager entityrenderermanager = Minecraft.getInstance().getRenderManager();
|
||||
quaternion1.conjugate();
|
||||
entityrenderermanager.setCameraOrientation(quaternion1);
|
||||
entityrenderermanager.setRenderShadow(false);
|
||||
IRenderTypeBuffer.Impl buff = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
|
||||
entityrenderermanager.renderEntityStatic(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, matrixstack, buff, 15728880);
|
||||
buff.finish();
|
||||
entityrenderermanager.setRenderShadow(true);
|
||||
entity.renderYawOffset = f2;
|
||||
entity.rotationYaw = f3;
|
||||
entity.rotationPitch = f4;
|
||||
entity.prevRotationYawHead = f5;
|
||||
entity.rotationYawHead = f6;
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.ellpeck.naturesaura.items;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
|
@ -9,6 +9,11 @@ import de.ellpeck.naturesaura.api.aura.container.ItemAuraContainer;
|
|||
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
|
||||
import de.ellpeck.naturesaura.api.render.ITrinketItem;
|
||||
import de.ellpeck.naturesaura.enchant.ModEnchantments;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
@ -110,14 +115,14 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
|
|||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(ItemStack stack, PlayerEntity player, RenderType type, boolean isHolding) {
|
||||
public void render(ItemStack stack, PlayerEntity player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding) {
|
||||
if (type == RenderType.BODY && !isHolding) {
|
||||
boolean chest = !player.inventory.armorInventory.get(EquipmentSlotType.CHEST.getIndex()).isEmpty();
|
||||
boolean legs = !player.inventory.armorInventory.get(EquipmentSlotType.LEGS.getIndex()).isEmpty();
|
||||
GlStateManager.translatef(-0.15F, 0.65F, chest ? -0.195F : legs ? -0.165F : -0.1475F);
|
||||
GlStateManager.scalef(0.25F, 0.25F, 0.25F);
|
||||
GlStateManager.rotatef(180F, 1F, 0F, 0F);
|
||||
//Helper.renderItemInWorld(stack);
|
||||
matrices.translate(-0.15F, 0.65F, chest ? -0.195F : legs ? -0.165F : -0.1475F);
|
||||
matrices.scale(0.5F, 0.5F, 0.5F);
|
||||
matrices.rotate(Vector3f.XP.rotationDegrees(180F));
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND, packedLight, OverlayTexture.DEFAULT_LIGHT, matrices, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package de.ellpeck.naturesaura.items;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.render.ITrinketItem;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -18,13 +22,13 @@ public class ItemEye extends ItemImpl implements ITrinketItem {
|
|||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(ItemStack stack, PlayerEntity player, RenderType type, boolean isHolding) {
|
||||
public void render(ItemStack stack, PlayerEntity player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding) {
|
||||
if (type == RenderType.BODY && !isHolding) {
|
||||
boolean armor = !player.inventory.armorInventory.get(EquipmentSlotType.CHEST.getIndex()).isEmpty();
|
||||
GlStateManager.translatef(0.1F, 0.225F, armor ? -0.195F : -0.1475F);
|
||||
GlStateManager.scalef(0.15F, 0.15F, 0.15F);
|
||||
GlStateManager.rotatef(180F, 1F, 0F, 0F);
|
||||
//Helper.renderItemInWorld(stack);
|
||||
matrices.translate(0.1F, 0.225F, armor ? -0.195F : -0.1475F);
|
||||
matrices.scale(0.3F, 0.3F, 0.3F);
|
||||
matrices.rotate(Vector3f.XP.rotationDegrees(180));
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND, packedLight, OverlayTexture.DEFAULT_LIGHT, matrices, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.ellpeck.naturesaura.items;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.render.ITrinketItem;
|
||||
|
@ -11,8 +11,10 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
@ -22,7 +24,6 @@ import net.minecraft.nbt.CompoundNBT;
|
|||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -34,8 +35,6 @@ import java.util.List;
|
|||
|
||||
public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem {
|
||||
|
||||
private static final ResourceLocation RES_WORN = new ResourceLocation(NaturesAura.MOD_ID, "textures/items/shockwave_creator_player.png");
|
||||
|
||||
public ItemShockwaveCreator() {
|
||||
super("shockwave_creator", new Properties().maxStackSize(1).group(NaturesAura.CREATIVE_TAB));
|
||||
}
|
||||
|
@ -109,24 +108,13 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem {
|
|||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(ItemStack stack, PlayerEntity player, RenderType type, boolean isHolding) {
|
||||
public void render(ItemStack stack, PlayerEntity player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding) {
|
||||
if (type == RenderType.BODY && !isHolding) {
|
||||
boolean armor = !player.inventory.armorInventory.get(EquipmentSlotType.CHEST.getIndex()).isEmpty();
|
||||
GlStateManager.translatef(-0.1675F, -0.05F, armor ? -0.195F : -0.1475F);
|
||||
GlStateManager.scalef(0.021F, 0.021F, 0.021F);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.pushTextureAttributes();
|
||||
GlStateManager.pushLightingAttributes();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(RES_WORN);
|
||||
Screen.blit(0, 0, 0, 0, 16, 16, 16, 16);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popAttributes();
|
||||
GlStateManager.popAttributes();
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.popMatrix();
|
||||
matrices.translate(0, 0.125F, armor ? -0.195F : -0.1475F);
|
||||
matrices.scale(0.3F, 0.3F, 0.3F);
|
||||
matrices.rotate(Vector3f.XP.rotationDegrees(180));
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND, packedLight, OverlayTexture.DEFAULT_LIGHT, matrices, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package de.ellpeck.naturesaura.renderers;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.naturesaura.api.render.ITrinketItem;
|
||||
import de.ellpeck.naturesaura.api.render.ITrinketItem.RenderType;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.entity.IEntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
|
||||
import net.minecraft.client.renderer.entity.model.PlayerModel;
|
||||
import net.minecraft.entity.Pose;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -33,7 +33,6 @@ public class PlayerLayerTrinkets extends LayerRenderer<AbstractClientPlayerEntit
|
|||
super(entityRendererIn);
|
||||
}
|
||||
|
||||
// TODO Fix this
|
||||
@Override
|
||||
public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, AbstractClientPlayerEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
|
||||
if (player.getActivePotionEffect(Effects.INVISIBILITY) != null)
|
||||
|
@ -42,26 +41,21 @@ public class PlayerLayerTrinkets extends LayerRenderer<AbstractClientPlayerEntit
|
|||
ItemStack second = player.getHeldItemOffhand();
|
||||
|
||||
this.alreadyRendered.clear();
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.pushLightingAttributes();
|
||||
RenderSystem.pushTextureAttributes();
|
||||
RenderSystem.color4f(1F, 1F, 1F, 1F);
|
||||
this.render(player, RenderType.BODY, main, second);
|
||||
matrixStackIn.push();
|
||||
this.render(player, RenderType.BODY, main, second, matrixStackIn, bufferIn, packedLightIn);
|
||||
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;
|
||||
RenderSystem.rotatef(yawOffset, 0, -1, 0);
|
||||
RenderSystem.rotatef(yaw - 270, 0, 1, 0);
|
||||
RenderSystem.rotatef(pitch, 0, 0, 1);
|
||||
this.render(player, RenderType.HEAD, main, second);
|
||||
RenderSystem.popAttributes();
|
||||
RenderSystem.popAttributes();
|
||||
RenderSystem.popMatrix();
|
||||
matrixStackIn.rotate(Vector3f.YN.rotationDegrees(yawOffset));
|
||||
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(yaw - 270));
|
||||
matrixStackIn.rotate(Vector3f.ZP.rotationDegrees(pitch));
|
||||
this.render(player, RenderType.HEAD, main, second, matrixStackIn, bufferIn, packedLightIn);
|
||||
matrixStackIn.pop();
|
||||
}
|
||||
|
||||
private void render(PlayerEntity player, RenderType type, ItemStack main, ItemStack second) {
|
||||
private void render(PlayerEntity player, RenderType type, ItemStack main, ItemStack second, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight) {
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||
this.renderStack(player.inventory.getStackInSlot(i), player, type, main, second);
|
||||
this.renderStack(player.inventory.getStackInSlot(i), player, type, main, second, matrices, buffer, packedLight);
|
||||
}
|
||||
|
||||
if (Compat.hasCompat("curios")) {
|
||||
|
@ -69,24 +63,24 @@ public class PlayerLayerTrinkets extends LayerRenderer<AbstractClientPlayerEntit
|
|||
if (handler != null) {
|
||||
for (IItemHandler items : handler.getCurioMap().values()) {
|
||||
for (int i = 0; i < items.getSlots(); i++) {
|
||||
this.renderStack(items.getStackInSlot(i), player, type, main, second);
|
||||
this.renderStack(items.getStackInSlot(i), player, type, main, second, matrices, buffer, packedLight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderStack(ItemStack stack, PlayerEntity player, RenderType type, ItemStack main, ItemStack second) {
|
||||
private void renderStack(ItemStack stack, PlayerEntity player, RenderType type, ItemStack main, ItemStack second, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight) {
|
||||
if (!stack.isEmpty()) {
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof ITrinketItem && !this.alreadyRendered.contains(item)) {
|
||||
GlStateManager.pushMatrix();
|
||||
if (type == RenderType.BODY && player.isShiftKeyDown()) {
|
||||
GlStateManager.translatef(0F, 0.2F, 0F);
|
||||
GlStateManager.rotatef(90F / (float) Math.PI, 1.0F, 0.0F, 0.0F);
|
||||
matrices.push();
|
||||
if (type == RenderType.BODY && player.getPose() == Pose.CROUCHING) {
|
||||
matrices.translate(0F, 0.2F, 0F);
|
||||
matrices.rotate(Vector3f.XP.rotationDegrees(90F / (float) Math.PI));
|
||||
}
|
||||
((ITrinketItem) item).render(stack, player, type, stack == main || stack == second);
|
||||
GlStateManager.popMatrix();
|
||||
((ITrinketItem) item).render(stack, player, type, matrices, buffer, packedLight, stack == main || stack == second);
|
||||
matrices.pop();
|
||||
this.alreadyRendered.add(item);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue