use of net.minecraft.client.gui.MapItemRenderer in project Charset by CharsetMC.
the class ProjectorHandlerMap method render.
@Override
@SideOnly(Side.CLIENT)
public void render(ItemStack stack, IProjector projector, IProjectorSurface surface) {
MapData mapData = ((ItemMap) stack.getItem()).getMapData(stack, surface.getWorld());
if (mapData != null && mapData.mapName != null) {
MapItemRenderer mapItemRenderer = Minecraft.getMinecraft().entityRenderer.getMapItemRenderer();
mapItemRenderer.updateMapTexture(mapData);
Object o = mapItemRenderer.getMapInstanceIfExists(mapData.mapName);
if (o != null) {
if (MAP_DATA_LOCATION_GETTER == null) {
MAP_DATA_LOCATION_GETTER = MethodHandleHelper.findFieldGetter(o.getClass(), "location", "field_148240_d");
}
try {
Minecraft.getMinecraft().getTextureManager().bindTexture((ResourceLocation) MAP_DATA_LOCATION_GETTER.invoke(o));
ProjectorHelper.INSTANCE.renderTexture(surface, 0, 256, 0, 256);
} catch (Throwable e) {
e.printStackTrace();
}
}
} else {
PacketRequestMapData.requestMap(stack);
}
}
Aggregations