use of net.minecraftforge.common.property.IExtendedBlockState in project MinecraftForge by MinecraftForge.
the class AnimationTESR method renderTileEntityFast.
public void renderTileEntityFast(@Nonnull T te, double x, double y, double z, float partialTick, int breakStage, @Nonnull VertexBuffer renderer) {
if (!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)) {
return;
}
if (blockRenderer == null)
blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos pos = te.getPos();
IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
IBlockState state = world.getBlockState(pos);
if (state.getPropertyKeys().contains(Properties.StaticProperty)) {
state = state.withProperty(Properties.StaticProperty, false);
}
if (state instanceof IExtendedBlockState) {
IExtendedBlockState exState = (IExtendedBlockState) state;
if (exState.getUnlistedNames().contains(Properties.AnimationProperty)) {
float time = Animation.getWorldTime(getWorld(), partialTick);
IAnimationStateMachine capability = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
if (capability != null) {
Pair<IModelState, Iterable<Event>> pair = capability.apply(time);
handleEvents(te, time, pair.getRight());
// TODO: caching?
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft());
renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false);
}
}
}
}
use of net.minecraftforge.common.property.IExtendedBlockState in project MinecraftForge by MinecraftForge.
the class BlockFluidBase method getExtendedState.
@Override
@Nonnull
public IBlockState getExtendedState(@Nonnull IBlockState oldState, @Nonnull IBlockAccess worldIn, @Nonnull BlockPos pos) {
IExtendedBlockState state = (IExtendedBlockState) oldState;
state = state.withProperty(FLOW_DIRECTION, (float) getFlowDirection(worldIn, pos));
float[][] height = new float[3][3];
float[][] corner = new float[2][2];
height[1][1] = getFluidHeightForRender(worldIn, pos);
if (height[1][1] == 1) {
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
corner[i][j] = 1;
}
}
} else {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != 1 || j != 1) {
height[i][j] = getFluidHeightForRender(worldIn, pos.add(i - 1, 0, j - 1));
}
}
}
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
corner[i][j] = getFluidHeightAverage(height[i][j], height[i][j + 1], height[i + 1][j], height[i + 1][j + 1]);
}
}
}
state = state.withProperty(LEVEL_CORNERS[0], corner[0][0]);
state = state.withProperty(LEVEL_CORNERS[1], corner[0][1]);
state = state.withProperty(LEVEL_CORNERS[2], corner[1][1]);
state = state.withProperty(LEVEL_CORNERS[3], corner[1][0]);
return state;
}
use of net.minecraftforge.common.property.IExtendedBlockState in project AgriCraft by AgriCraft.
the class RenderCrop method renderWorldBlockStatic.
@Override
public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, BlockCrop block, EnumFacing side) {
TextureAtlasSprite sprite = RenderCrop.getIcon(TEXTURE);
this.renderBaseQuads(tessellator, side, sprite);
if (state instanceof IExtendedBlockState) {
IExtendedBlockState extendedState = (IExtendedBlockState) state;
IAgriPlant plant = extendedState.getValue(AgriProperties.CROP_PLANT);
int growthstage = extendedState.getValue(AgriProperties.GROWTH_STAGE);
if (extendedState.getValue(AgriProperties.CROSS_CROP)) {
tessellator.drawScaledPrism(0, 10, 2, 16, 11, 3, sprite);
tessellator.drawScaledPrism(0, 10, 13, 16, 11, 14, sprite);
tessellator.drawScaledPrism(2, 10, 0, 3, 11, 16, sprite);
tessellator.drawScaledPrism(13, 10, 0, 14, 11, 16, sprite);
}
if (plant != null) {
tessellator.addQuads(plant.getPlantQuads(extendedState, growthstage, side, tessellator));
}
}
}
use of net.minecraftforge.common.property.IExtendedBlockState in project AgriCraft by AgriCraft.
the class RenderSprinkler method renderWorldBlockStatic.
@Override
public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, BlockSprinkler block, EnumFacing side) {
tessellator.translate(0, 4 * Constants.UNIT, 0);
CustomWoodType type;
if (state instanceof IExtendedBlockState) {
type = ((IExtendedBlockState) state).getValue(AgriProperties.CUSTOM_WOOD_TYPE);
} else {
type = CustomWoodTypeRegistry.DEFAULT;
}
tessellator.drawScaledPrism(4, 8, 4, 12, 16, 12, type.getIcon());
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class TileRenderBelljar method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityBelljar tile, double x, double y, double z, float partialTicks, int destroyStage) {
if (tile.dummy != 0 || !tile.getWorld().isBlockLoaded(tile.getPos(), false))
return;
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos blockPos = tile.getPos();
if (!quads.containsKey(tile.getFacing())) {
IBlockState state = getWorld().getBlockState(blockPos);
if (state.getBlock() != IEContent.blockMetalDevice1)
return;
state = state.getActualState(getWorld(), blockPos);
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
if (state instanceof IExtendedBlockState)
state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Arrays.asList("glass"), true));
quads.put(tile.getFacing(), model.getQuads(state, null, 0));
}
ClientUtils.bindAtlas();
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
VertexBuffer worldRenderer = Tessellator.getInstance().getBuffer();
GlStateManager.enableCull();
IPlantHandler plantHandler = tile.getCurrentPlantHandler();
if (plantHandler != null) {
GlStateManager.pushMatrix();
GlStateManager.translate(0, 1.0625, 0);
GlStateManager.color(1, 1, 1, 1);
float scale = plantHandler.getRenderSize(tile.getInventory()[1], tile.getInventory()[0], tile.renderGrowth, tile);
GlStateManager.translate((1 - scale) / 2, 0, (1 - scale) / 2);
GlStateManager.scale(scale, scale, scale);
if (!plantHandler.overrideRender(tile.getInventory()[1], tile.getInventory()[0], tile.renderGrowth, tile, blockRenderer)) {
IBlockState[] states = plantHandler.getRenderedPlant(tile.getInventory()[1], tile.getInventory()[0], tile.renderGrowth, tile);
if (states == null || states.length < 1)
return;
for (IBlockState s : states) {
List<BakedQuad> plantQuadList = plantQuads.get(s);
if (plantQuadList == null) {
IBakedModel plantModel = blockRenderer.getModelForState(s);
plantQuadList = plantModel.getQuads(s, null, 0);
for (EnumFacing f : EnumFacing.values()) plantQuadList.addAll(plantModel.getQuads(s, f, 0));
plantQuads.put(s, plantQuadList);
}
if (plantQuadList != null) {
GlStateManager.pushMatrix();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
ClientUtils.renderModelTESR(plantQuadList, worldRenderer, tile.getWorld().getCombinedLight(tile.getPos(), 0));
Tessellator.getInstance().draw();
GlStateManager.popMatrix();
GlStateManager.translate(0, 1, 0);
}
}
}
GlStateManager.popMatrix();
}
GlStateManager.depthMask(false);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
ClientUtils.renderModelTESR(quads.get(tile.getFacing()), worldRenderer, tile.getWorld().getCombinedLight(tile.getPos(), 0));
Tessellator.getInstance().draw();
RenderHelper.enableStandardItemLighting();
GlStateManager.disableBlend();
GlStateManager.depthMask(true);
GlStateManager.popMatrix();
RenderHelper.enableStandardItemLighting();
}
Aggregations