81 lines
2.1 KiB
Java
81 lines
2.1 KiB
Java
/**
|
|
* Copyright (c) 2011-2017, SpaceToad and the BuildCraft Team
|
|
* http://www.mod-buildcraft.com
|
|
* <p/>
|
|
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
|
* License 1.0, or MMPL. Please check the contents of the license located in
|
|
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
|
*/
|
|
package buildcraft.core.render;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
|
|
|
import buildcraft.BuildCraftCore;
|
|
import buildcraft.core.lib.render.IInventoryRenderer;
|
|
|
|
public class RenderingEntityBlocks extends BCSimpleBlockRenderingHandler {
|
|
|
|
public static HashMap<EntityRenderIndex, IInventoryRenderer> blockByEntityRenders = new HashMap<EntityRenderIndex, IInventoryRenderer>();
|
|
|
|
public static class EntityRenderIndex {
|
|
Block block;
|
|
int damage;
|
|
|
|
public EntityRenderIndex(Block block, int damage) {
|
|
this.block = block;
|
|
this.damage = damage;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return block.hashCode() + damage;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (!(o instanceof EntityRenderIndex)) {
|
|
return false;
|
|
}
|
|
|
|
EntityRenderIndex i = (EntityRenderIndex) o;
|
|
|
|
return i.block == block && i.damage == damage;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
|
if (block.getRenderType() == BuildCraftCore.blockByEntityModel) {
|
|
EntityRenderIndex index = new EntityRenderIndex(block, metadata);
|
|
if (blockByEntityRenders.containsKey(index)) {
|
|
blockByEntityRenders.get(index).inventoryRender(-0.5, -0.5, -0.5, 0, 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
|
if (block.getRenderType() == BuildCraftCore.blockByEntityModel) {
|
|
// renderblocks.renderStandardBlock(block, i, j, k);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean shouldRender3DInInventory(int modelId) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public int getRenderId() {
|
|
return BuildCraftCore.blockByEntityModel;
|
|
}
|
|
}
|