use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class IESmartObjModel method getQuads.
@Override
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand) {
OBJState objState = null;
Map<String, String> tex = null;
if (blockState instanceof IExtendedBlockState) {
IExtendedBlockState ext = (IExtendedBlockState) blockState;
if (ext.getUnlistedNames().contains(Properties.AnimationProperty)) {
IModelState modState = ext.getValue(Properties.AnimationProperty);
if (modState instanceof OBJState)
objState = (OBJState) modState;
}
if (ext.getUnlistedNames().contains(IEProperties.OBJ_TEXTURE_REMAP))
tex = ext.getValue(IEProperties.OBJ_TEXTURE_REMAP);
}
return getQuads(blockState, side, rand, objState, tex, false);
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class IESmartObjModel method getQuads.
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand, OBJState objstate, Map<String, String> tex, boolean addAnimationAndTex) {
texReplace = tex;
this.tempState = blockState;
if (blockState instanceof IExtendedBlockState) {
IExtendedBlockState exState = (IExtendedBlockState) blockState;
ExtBlockstateAdapter adapter;
if (objstate != null) {
if (objstate.parent == null || objstate.parent == TRSRTransformation.identity())
objstate.parent = this.getState();
if (objstate.getVisibilityMap().containsKey(Group.ALL) || objstate.getVisibilityMap().containsKey(Group.ALL_EXCEPT))
this.updateStateVisibilityMap(objstate);
}
if (addAnimationAndTex)
adapter = new ExtBlockstateAdapter(exState, MinecraftForgeClient.getRenderLayer(), ExtBlockstateAdapter.CONNS_OBJ_CALLBACK, new Object[] { objstate, tex });
else
adapter = new ExtBlockstateAdapter(exState, MinecraftForgeClient.getRenderLayer(), ExtBlockstateAdapter.CONNS_OBJ_CALLBACK);
if (!modelCache.containsKey(adapter)) {
IESmartObjModel model = null;
if (objstate != null)
model = new IESmartObjModel(baseModel, getModel(), objstate, getFormat(), getTextures(), transformationMap);
if (model == null)
model = new IESmartObjModel(baseModel, getModel(), this.getState(), getFormat(), getTextures(), transformationMap);
model.tempState = blockState;
model.texReplace = tex;
modelCache.put(adapter, model.buildQuads());
}
return Collections.synchronizedList(Lists.newArrayList(modelCache.get(adapter)));
}
if (bakedQuads == null)
bakedQuads = buildQuads();
List<BakedQuad> quadList = Collections.synchronizedList(Lists.newArrayList(bakedQuads));
return quadList;
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class ModelConveyor method getQuads.
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState blockState, @Nullable EnumFacing side, long rand) {
TileEntity tile = null;
String key = "default";
EnumFacing facing = EnumFacing.NORTH;
if (blockState == null)
key = conveyor != null ? ConveyorHandler.reverseClassRegistry.get(conveyor.getClass()).toString() : "immersiveengineering:conveyor";
else {
facing = blockState.getValue(IEProperties.FACING_ALL);
if (blockState instanceof IExtendedBlockState) {
IExtendedBlockState exState = (IExtendedBlockState) blockState;
if (exState.getUnlistedNames().contains(BlockConveyor.ICONEYOR_PASSTHROUGH))
conveyor = ((IExtendedBlockState) blockState).getValue(BlockConveyor.ICONEYOR_PASSTHROUGH);
if (exState.getUnlistedNames().contains(IEProperties.TILEENTITY_PASSTHROUGH))
tile = ((IExtendedBlockState) blockState).getValue(IEProperties.TILEENTITY_PASSTHROUGH);
if (conveyor != null && tile != null)
key = conveyor.getModelCacheKey(tile, facing);
}
}
List<BakedQuad> cachedQuads = modelCache.get(key);
if (cachedQuads != null)
return Collections.synchronizedList(Lists.newArrayList(cachedQuads));
else {
cachedQuads = Collections.synchronizedList(Lists.newArrayList());
Matrix4f facingMatrix = TRSRTransformation.getMatrix(facing);
if (conveyor != null)
facingMatrix = conveyor.modifyBaseRotationMatrix(facingMatrix, tile, facing);
Matrix4 matrix = new Matrix4(facingMatrix);
ConveyorDirection conDir = conveyor != null ? conveyor.getConveyorDirection() : ConveyorDirection.HORIZONTAL;
boolean[] walls = conveyor != null && tile != null ? new boolean[] { conveyor.renderWall(tile, facing, 0), conveyor.renderWall(tile, facing, 1) } : new boolean[] { true, true };
TextureAtlasSprite tex_conveyor = ClientUtils.mc().getTextureMapBlocks().getMissingSprite();
TextureAtlasSprite tex_conveyor_colour = null;
int colourStripes = -1;
if (conveyor != null) {
tex_conveyor = ClientUtils.getSprite(tile != null ? (conveyor.isActive(tile) ? conveyor.getActiveTexture() : conveyor.getInactiveTexture()) : conveyor.getActiveTexture());
if ((colourStripes = conveyor.getDyeColour()) >= 0)
tex_conveyor_colour = ClientUtils.getSprite(conveyor.getColouredStripesTexture());
}
cachedQuads.addAll(getBaseConveyor(facing, 1, matrix, conDir, tex_conveyor, walls, new boolean[] { true, true }, tex_conveyor_colour, colourStripes));
if (conveyor != null)
cachedQuads = conveyor.modifyQuads(cachedQuads, tile, facing);
modelCache.put(key, cachedQuads);
return Collections.synchronizedList(Lists.newArrayList(cachedQuads));
}
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class ConnModelReal method getQuads.
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
if (side == null && state instanceof IExtendedBlockState) {
IExtendedBlockState iExtendedBlockState = (IExtendedBlockState) state;
ExtBlockstateAdapter ad = new ExtBlockstateAdapter(iExtendedBlockState, null, ExtBlockstateAdapter.ONLY_OBJ_CALLBACK);
int x = 0, z = 0;
if (iExtendedBlockState.getUnlistedProperties().containsKey(IEProperties.CONNECTIONS)) {
Set<Connection> conns = iExtendedBlockState.getValue(IEProperties.CONNECTIONS);
if (conns != null && conns.size() > 0) {
BlockPos tmp = conns.iterator().next().start;
x = (tmp.getX() % 16 + 16) % 16;
z = (tmp.getZ() % 16 + 16) % 16;
}
}
Pair<Byte, ExtBlockstateAdapter> key = new ImmutablePair<>((byte) ((x << 4) | z), ad);
IBakedModel ret = cache.get(key);
if (ret == null) {
ret = new AssembledBakedModel(iExtendedBlockState, textureAtlasSprite, base, rand);
cache.put(key, ret);
}
return ret.getQuads(state, side, rand);
}
return base.getQuads(state, side, rand);
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class TileRenderArcFurnace method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityArcFurnace te, double x, double y, double z, float partialTicks, int destroyStage) {
if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
return;
List<String> renderedParts = null;
for (int i = 0; i < 3; i++) if (te.getInventory()[23 + i] != null) {
if (renderedParts == null)
renderedParts = Lists.newArrayList("electrode" + (i + 1));
else
renderedParts.add("electrode" + (i + 1));
}
if (renderedParts == null)
return;
if (te.shouldRenderAsActive())
renderedParts.add("active");
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos blockPos = te.getPos();
IBlockState state = getWorld().getBlockState(blockPos);
if (state.getBlock() != IEContent.blockMetalMultiblock)
return;
state = state.getBlock().getActualState(state, getWorld(), blockPos);
state = state.withProperty(IEProperties.DYNAMICRENDER, true);
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
if (state instanceof IExtendedBlockState)
state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(renderedParts, true));
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer worldRenderer = tessellator.getBuffer();
ClientUtils.bindAtlas();
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
GlStateManager.translate(.5, .5, .5);
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 - blockPos.getX(), -.5 - blockPos.getY(), -.5 - blockPos.getZ());
worldRenderer.color(255, 255, 255, 255);
blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer, true);
worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
RenderHelper.enableStandardItemLighting();
GlStateManager.popMatrix();
}
Aggregations