use of net.minecraftforge.common.property.IExtendedBlockState in project AgriCraft by AgriCraft.
the class RenderBlockCustomWood method renderWorldBlockStatic.
@Override
public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, B block, EnumFacing side) {
if (state instanceof IExtendedBlockState) {
CustomWoodType type = ((IExtendedBlockState) state).getValue(AgriProperties.CUSTOM_WOOD_TYPE);
this.renderWorldBlockWoodStatic(tessellator, (IExtendedBlockState) state, block, side, type.getIcon());
}
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class TileRenderTurret method renderModelPart.
public static void renderModelPart(final BlockRendererDispatcher blockRenderer, Tessellator tessellator, VertexBuffer worldRenderer, World world, IBlockState state, IBakedModel model, BlockPos pos, String... parts) {
if (state instanceof IExtendedBlockState)
state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Arrays.asList(parts), true));
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-.5 - pos.getX(), -.5 - pos.getY(), -.5 - pos.getZ());
worldRenderer.color(255, 255, 255, 255);
blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, worldRenderer, true);
worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class TileRenderAutoWorkbench method renderModelPart.
public static void renderModelPart(final BlockRendererDispatcher blockRenderer, Tessellator tessellator, VertexBuffer worldRenderer, World world, IBlockState state, IBakedModel model, BlockPos pos, String... parts) {
if (state instanceof IExtendedBlockState)
state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Arrays.asList(parts), true));
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-.5 - pos.getX(), -.5 - pos.getY(), -.5 - pos.getZ());
worldRenderer.color(255, 255, 255, 255);
blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, worldRenderer, true);
worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
}
use of net.minecraftforge.common.property.IExtendedBlockState in project BetterWithAddons by DaedalusGame.
the class BlockRopeSideways method getExtendedState.
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
TileEntity te = world instanceof ChunkCache ? ((ChunkCache) world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos);
ItemStack planks = ItemStack.EMPTY;
if (te instanceof TileEntityRopeSideways) {
TileEntityRopeSideways tile = (TileEntityRopeSideways) te;
planks = tile.getPlanks();
}
return ((IExtendedBlockState) state).withProperty(HELD_PLANKS, planks);
}
use of net.minecraftforge.common.property.IExtendedBlockState in project Charset by CharsetMC.
the class RenderTileEntityStacks method getQuads.
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
if (side != null || !(state instanceof IExtendedBlockState)) {
return Collections.emptyList();
}
TileEntityStacks stacks = ((IExtendedBlockState) state).getValue(BlockStacks.PROPERTY_TILE);
if (stacks == null || stacks.stacks.isEmpty()) {
return Collections.emptyList();
}
List<BakedQuad> list = new ArrayList<>();
int i = 0;
for (ItemMaterial material : stacks.stacks) {
Vec3d[] vecs = INGOT_POSITIONS[i];
ItemMaterial blockMaterial = material.getRelated("block");
TextureAtlasSprite sprite;
int c;
if (blockMaterial == null) {
ItemStack ingotStack = material.getStack();
sprite = RenderUtils.getItemSprite(new ItemStack(Blocks.IRON_BLOCK));
c = ColorLookupHandler.INSTANCE.getColor(ingotStack, RenderUtils.AveragingMode.FULL) | 0xFF000000;
} else {
sprite = RenderUtils.getItemSprite(blockMaterial.getStack());
c = Minecraft.getMinecraft().getItemColors().colorMultiplier(blockMaterial.getStack(), 0);
}
float[] color = new float[] { MathHelper.clamp(((c >> 16) & 0xFF) / 255.0f, 0, 1), MathHelper.clamp(((c >> 8) & 0xFF) / 255.0f, 0, 1), MathHelper.clamp(((c) & 0xFF) / 255.0f, 0, 1), 1.0f };
int j = 0;
int yOff = (i >> 3) & 1;
for (int[] vecOrder : QUAD_ORDERS[yOff]) {
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(DefaultVertexFormats.ITEM);
EnumFacing face = QUAD_FACES[yOff][j];
builder.setTexture(sprite);
builder.setApplyDiffuseLighting(isAmbientOcclusion());
builder.setContractUVs(false);
builder.setQuadOrientation(face);
int uv_offset = j < 4 ? 1 : 0;
if (yOff == 1)
uv_offset = 1 - uv_offset;
for (int k = 0; k < vecOrder.length; k++) {
Vec3d vec = vecs[vecOrder[k]];
int[] uv = QUAD_UVS[(k + uv_offset) & 3];
for (int e = 0; e < builder.getVertexFormat().getElementCount(); e++) {
VertexFormatElement el = builder.getVertexFormat().getElement(e);
switch(el.getUsage()) {
case POSITION:
builder.put(e, (float) vec.x / 16f, (float) vec.y / 16f, (float) vec.z / 16f, 1);
break;
case COLOR:
builder.put(e, color);
break;
case NORMAL:
builder.put(e, face.getFrontOffsetX(), face.getFrontOffsetY(), face.getFrontOffsetZ(), 0);
break;
case UV:
float u = sprite.getInterpolatedU(uv[0]);
float v = sprite.getInterpolatedV(uv[1]);
builder.put(e, u, v, 0, 1);
break;
default:
builder.put(e);
}
}
}
list.add(builder.build());
j++;
}
i++;
}
return list;
}
Aggregations