Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering fixes #303

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import nova.core.entity.EntityFactory;
import nova.core.language.LanguageManager;
import nova.core.wrapper.mc.forge.v17.NovaMinecraftPreloader;
import nova.core.wrapper.mc.forge.v17.render.RenderUtility;
import nova.core.wrapper.mc.forge.v17.wrapper.render.RenderUtility;
import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock;
import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWTile;
import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWTileRenderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.IIconRegister;
Expand Down Expand Up @@ -60,7 +61,7 @@
import nova.core.wrapper.mc.forge.v17.wrapper.cuboid.CuboidConverter;
import nova.core.wrapper.mc.forge.v17.wrapper.entity.EntityConverter;
import nova.core.wrapper.mc.forge.v17.wrapper.item.ItemConverter;
import nova.core.wrapper.mc.forge.v17.wrapper.render.BWModel;
import nova.core.wrapper.mc.forge.v17.wrapper.render.backward.BWModel;
import nova.internal.core.Game;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.lwjgl.opengl.GL11;
Expand Down Expand Up @@ -153,7 +154,6 @@ public Block getBlockInstance(net.minecraft.world.IBlockAccess access, Vector3D
}
}
return getBlockInstance(WorldConverter.instance().toNova(access), position);

}

private Block getBlockInstance(nova.core.world.World world, Vector3D position) {
Expand Down Expand Up @@ -226,31 +226,12 @@ public TileEntity createTileEntity(World world, int metadata) {

@Override
public IIcon getIcon(IBlockAccess access, int x, int y, int z, int side) {
//TODO: Fill in something
/*
Block blockInstance = getBlockInstance(access, new Vector3D(x, y, z));
Optional<StaticBlockRenderer> opRenderer = blockInstance.components.getOp(StaticBlockRenderer.class);
if (opRenderer.isPresent()) {
Optional<Texture> texture = opRenderer.components.get().texture.apply(Direction.values()[side]);
if (texture.isPresent()) {
return RenderUtility.instance.getIcon(texture.components.get());
}
}*/
return null;
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("missingno");
}

@Override
public IIcon getIcon(int side, int meta) {
//TODO: Fill in something
/*
Optional<StaticBlockRenderer> opRenderer = block.components.getOp(StaticBlockRenderer.class);
if (opRenderer.isPresent()) {
Optional<Texture> texture = opRenderer.components.get().texture.apply(Direction.values()[side]);
if (texture.isPresent()) {
return RenderUtility.instance.getIcon(texture.components.get());
}
}*/
return null;
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("missingno");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import net.minecraft.tileentity.TileEntity;
import nova.core.block.Block;
import nova.core.component.renderer.DynamicRenderer;
import nova.core.wrapper.mc.forge.v17.render.RenderUtility;
import nova.core.wrapper.mc.forge.v17.wrapper.render.BWModel;
import nova.core.wrapper.mc.forge.v17.wrapper.render.RenderUtility;
import nova.core.wrapper.mc.forge.v17.wrapper.render.backward.BWModel;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import nova.core.entity.Entity;
import nova.core.entity.EntityFactory;
import nova.core.util.shape.Cuboid;
import nova.core.wrapper.mc.forge.v17.render.RenderUtility;
import nova.core.wrapper.mc.forge.v17.wrapper.render.RenderUtility;
import nova.core.wrapper.mc.forge.v17.util.WrapperEvent;
import nova.internal.core.Game;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import nova.core.component.renderer.DynamicRenderer;
import nova.core.wrapper.mc.forge.v17.render.RenderUtility;
import nova.core.wrapper.mc.forge.v17.wrapper.render.BWModel;
import nova.core.wrapper.mc.forge.v17.wrapper.render.RenderUtility;
import nova.core.wrapper.mc.forge.v17.wrapper.render.backward.BWModel;
import org.lwjgl.opengl.GL11;

import java.util.Optional;
Expand Down Expand Up @@ -65,7 +65,7 @@ public static void render(Entity wrapper, nova.core.entity.Entity entity, double
}

Tessellator.instance.startDrawingQuads();
model.render(Optional.of(RenderManager.instance));
model.render(RenderManager.instance);
Tessellator.instance.draw();

if (model.blendSFactor > 0 && model.blendDFactor > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import nova.core.item.ItemFactory;

Expand All @@ -47,8 +46,9 @@ public ItemFactory getItemFactory() {
}

@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) {
ItemWrapperMethods.super.addInformation(itemStack, player, list, p_77624_4_);
@SuppressWarnings({"unchecked", "rawtypes"})
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean advanced) {
ItemWrapperMethods.super.addInformation(itemStack, player, list, advanced);
}

@Override
Expand All @@ -62,24 +62,12 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer
}

@Override
public IIcon getIconFromDamage(int p_77617_1_) {
return ItemWrapperMethods.super.getIconFromDamage(p_77617_1_);
public int getColorFromItemStack(ItemStack stack, int layer) {
return ItemWrapperMethods.super.getColorFromItemStack(stack, layer);
}

@Override
public IIcon getIcon(ItemStack itemStack, int pass) {
return ItemWrapperMethods.super.getIcon(itemStack, pass);
}

@Override
public int getColorFromItemStack(ItemStack p_82790_1_, int p_82790_2_) {
return ItemWrapperMethods.super.getColorFromItemStack(p_82790_1_, p_82790_2_);
}

@Override
public void registerIcons(IIconRegister ir) {

}
public void registerIcons(IIconRegister ir) {}

@Override
public String getUnlocalizedName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import nova.core.item.ItemFactory;
import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock;
Expand All @@ -45,8 +44,9 @@ public ItemFactory getItemFactory() {
}

@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) {
ItemWrapperMethods.super.addInformation(itemStack, player, list, p_77624_4_);
@SuppressWarnings({"unchecked", "rawtypes"})
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean advanced) {
ItemWrapperMethods.super.addInformation(itemStack, player, list, advanced);
}

@Override
Expand All @@ -60,24 +60,12 @@ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer
}

@Override
public IIcon getIconFromDamage(int p_77617_1_) {
return ItemWrapperMethods.super.getIconFromDamage(p_77617_1_);
public int getColorFromItemStack(ItemStack stack, int layer) {
return ItemWrapperMethods.super.getColorFromItemStack(stack, layer);
}

@Override
public IIcon getIcon(ItemStack itemStack, int pass) {
return ItemWrapperMethods.super.getIcon(itemStack, pass);
}

@Override
public int getColorFromItemStack(ItemStack p_82790_1_, int p_82790_2_) {
return ItemWrapperMethods.super.getColorFromItemStack(p_82790_1_, p_82790_2_);
}

@Override
public void registerIcons(IIconRegister ir) {

}
public void registerIcons(IIconRegister ir) {}

@Override
public String getUnlocalizedName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer;
import nova.core.component.renderer.DynamicRenderer;
import nova.core.component.renderer.Renderer;
import nova.core.component.renderer.StaticRenderer;
import nova.core.item.Item;
import nova.core.item.ItemFactory;
import nova.core.render.model.MeshModel;
import nova.core.render.pipeline.BlockRenderPipeline;
import nova.core.render.pipeline.StaticCubeTextureCoordinates;
import nova.core.util.Direction;
import nova.core.wrapper.mc.forge.v17.render.RenderUtility;
import nova.core.wrapper.mc.forge.v17.wrapper.entity.backward.BWEntity;
import nova.core.wrapper.mc.forge.v17.wrapper.render.BWModel;
import nova.core.wrapper.mc.forge.v17.wrapper.render.backward.BWModel;
import nova.internal.core.Game;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.lwjgl.opengl.GL11;
Expand All @@ -53,8 +52,7 @@ public interface ItemWrapperMethods extends IItemRenderer {

ItemFactory getItemFactory();

@SuppressWarnings({"unchecked", "rawtypes"})
default void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) {
default void addInformation(ItemStack itemStack, EntityPlayer player, List<String> list, boolean advanced) {
Item item = ItemConverter.instance().toNova(itemStack);
item.setCount(itemStack.stackSize).events.publish(new Item.TooltipEvent(Optional.of(new BWEntity(player)), list));
getItemFactory().save(item);
Expand All @@ -74,17 +72,9 @@ default ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlaye
return ItemConverter.instance().updateMCItemStack(itemStack, item);
}

default IIcon getIconFromDamage(int p_77617_1_) {
return null;
}

default IIcon getIcon(ItemStack itemStack, int pass) {
return null;
}

@Override
default boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
return item.getItem() == this && getIcon(item, 0) == null;
return item.getItem() == this;
}

@Override
Expand All @@ -101,9 +91,23 @@ default void renderItem(IItemRenderer.ItemRenderType type, ItemStack itemStack,
GL11.glPushMatrix();
Tessellator.instance.startDrawingQuads();
BWModel model = new BWModel();
model.matrix.rotate(Direction.UP.toVector(), 1 / 4 * Math.PI);
model.matrix.rotate(Direction.EAST.toVector(), 1 / 6 * Math.PI);
model.matrix.scale(1.6, 1.6, 1.6);
// TODO: Fix this
if (this instanceof FWItem)
switch (type) {
case EQUIPPED:
break;
case EQUIPPED_FIRST_PERSON:
// model.matrix.scale(1.7, 1.7, 1.7);
// model.matrix.translate(0, 1, 0.125);
// model.matrix.rotate(Direction.DOWN.toVector(), Math.PI * 5 / 4);
// model.matrix.rotate(Direction.NORTH.toVector(), Math.PI / 3);
break;
case INVENTORY:
model.matrix.rotate(Direction.DOWN.toVector(), Math.PI / 4);
model.matrix.rotate(Direction.EAST.toVector(), Math.PI / 6);
model.matrix.scale(1.6, 1.6, 1.6);
break;
}
item.components.getSet(Renderer.class).forEach(r -> r.onRender.accept(model));
model.render();
Tessellator.instance.draw();
Expand All @@ -113,7 +117,7 @@ default void renderItem(IItemRenderer.ItemRenderType type, ItemStack itemStack,
}

@SuppressWarnings("deprecation")
default int getColorFromItemStack(ItemStack itemStack, int p_82790_2_) {
default int getColorFromItemStack(ItemStack itemStack, int layer) {
return ItemConverter.instance().toNova(itemStack).colorMultiplier().argb();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with NOVA. If not, see <http://www.gnu.org/licenses/>.
*/

package nova.core.wrapper.mc.forge.v17.render;
package nova.core.wrapper.mc.forge.v17.wrapper.render;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
Expand All @@ -31,7 +31,6 @@
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.client.model.ModelFormatException;
import nova.core.render.texture.Texture;
import nova.core.wrapper.mc.forge.v17.launcher.ForgeLoadable;
import nova.core.wrapper.mc.forge.v17.wrapper.assets.AssetConverter;
Expand Down Expand Up @@ -110,6 +109,12 @@ public static void enableLightmap() {
}

public IIcon getIcon(Texture texture) {
if ("nova".equals(texture.domain)) {
switch (texture.name) {
case "null": return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(null);
}
}

if (iconMap.containsKey(texture)) {
return iconMap.get(texture);
}
Expand Down Expand Up @@ -177,7 +182,7 @@ public void preInit(FMLPreInitializationEvent event) {
IResource res = Minecraft.getMinecraft().getResourceManager().getResource(resource);
m.load(res.getInputStream());
} catch (IOException e) {
throw new ModelFormatException("IO Exception reading model format", e);
Game.logger().warn("IO Exception reading model format", e);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with NOVA. If not, see <http://www.gnu.org/licenses/>.
*/

package nova.core.wrapper.mc.forge.v17.wrapper.render;
package nova.core.wrapper.mc.forge.v17.wrapper.render.backward;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
Expand All @@ -30,8 +30,8 @@
import nova.core.render.texture.EntityTexture;
import nova.core.render.texture.Texture;
import nova.core.util.math.Vector3DUtil;
import nova.core.wrapper.mc.forge.v17.render.RenderUtility;
import nova.core.wrapper.mc.forge.v17.wrapper.assets.AssetConverter;
import nova.core.wrapper.mc.forge.v17.wrapper.render.RenderUtility;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;

import java.util.Optional;
Expand All @@ -43,17 +43,19 @@ public class BWModel extends MeshModel {

/**
* Completes this rendering for a block.
*
* @param access The world instance.
*/
public void render(IBlockAccess blockAccess) {
render(Optional.of(blockAccess), Optional.empty());
public void render(IBlockAccess access) {
render(Optional.of(access), Optional.empty());
}

public void render() {
render(Optional.empty(), Optional.empty());
}

public void render(Optional<RenderManager> entityRenderManager) {
render(Optional.empty(), entityRenderManager);
public void render(RenderManager entityRenderManager) {
render(Optional.empty(), Optional.of(entityRenderManager));
}

public void render(Optional<IBlockAccess> access, Optional<RenderManager> entityRenderManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import nova.core.entity.EntityFactory;
import nova.core.language.LanguageManager;
import nova.core.wrapper.mc.forge.v18.NovaMinecraftPreloader;
import nova.core.wrapper.mc.forge.v18.render.RenderUtility;
import nova.core.wrapper.mc.forge.v18.wrapper.render.RenderUtility;
import nova.core.wrapper.mc.forge.v18.wrapper.block.forward.FWBlock;
import nova.core.wrapper.mc.forge.v18.wrapper.block.forward.FWTile;
import nova.core.wrapper.mc.forge.v18.wrapper.block.forward.FWTileRenderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import net.minecraft.tileentity.TileEntity;
import nova.core.block.Block;
import nova.core.component.renderer.DynamicRenderer;
import nova.core.wrapper.mc.forge.v18.render.RenderUtility;
import nova.core.wrapper.mc.forge.v18.wrapper.render.BWModel;
import nova.core.wrapper.mc.forge.v18.wrapper.render.RenderUtility;
import nova.core.wrapper.mc.forge.v18.wrapper.render.backward.BWModel;

import java.util.Optional;

Expand Down
Loading