use of net.minecraftforge.common.property.IExtendedBlockState in project LogisticsPipes by RS485.
the class LogisticsNewPipeModel method bake.
@Override
@SideOnly(Side.CLIENT)
@Nonnull
public IBakedModel bake(@Nonnull IModelState state, @Nonnull VertexFormat format, @Nonnull Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
return new IBakedModel() {
private ArrayList<BakedQuad> quads = null;
@Override
@SideOnly(Side.CLIENT)
@Nonnull
public List<BakedQuad> getQuads(@Nullable IBlockState blockstate, @Nullable EnumFacing side, long rand) {
BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
ArrayList<BakedQuad> result;
if (layer == BlockRenderLayer.CUTOUT || layer == null || blockstate == null) {
result = getLPQuads(blockstate, side);
} else {
result = Lists.newArrayList();
}
addOtherQuads(result, blockstate, side, rand);
return result;
}
private void addOtherQuads(@Nonnull List<BakedQuad> list, IBlockState blockstate, EnumFacing side, long rand) {
if (blockstate != null) {
SimpleServiceLocator.mcmpProxy.addQuads(list, blockstate, side, rand);
}
}
private ArrayList<BakedQuad> getLPQuads(@Nullable IBlockState blockstate, @Nullable EnumFacing side) {
if (blockstate != null) {
if (side == null) {
IExtendedBlockState eState = (IExtendedBlockState) blockstate;
Cache<PipeRenderState.LocalCacheType, Object> objectCache = eState.getValue(LogisticsBlockGenericPipe.propertyCache);
if (objectCache != null) {
Object pipeQuads = objectCache.getIfPresent(PipeRenderState.LocalCacheType.QUADS);
if (pipeQuads instanceof Collection) {
// noinspection unchecked
return new ArrayList<>((Collection<? extends BakedQuad>) pipeQuads);
}
}
final ArrayList<BakedQuad> pipeQuads = LogisticsRenderPipe.secondRenderer.getQuadsFromRenderList(generatePipeRenderList(blockstate), format, true);
if (objectCache != null) {
objectCache.put(PipeRenderState.LocalCacheType.QUADS, new ArrayList<>(pipeQuads));
}
return pipeQuads;
}
} else {
if (quads == null) {
quads = LogisticsRenderPipe.secondRenderer.getQuadsFromRenderList(generatePipeRenderList(), format, true);
}
return new ArrayList<>(quads);
}
return Lists.newArrayList();
}
@Override
public boolean isAmbientOcclusion() {
return false;
}
@Override
public boolean isGui3d() {
return true;
}
@Override
public boolean isBuiltInRenderer() {
return false;
}
@Override
@Nonnull
public TextureAtlasSprite getParticleTexture() {
return BASE_TEXTURE_SPRITE;
}
@Override
@Nonnull
public ItemOverrideList getOverrides() {
return ItemOverrideList.NONE;
}
@Override
@Nonnull
public org.apache.commons.lang3.tuple.Pair<? extends IBakedModel, Matrix4f> handlePerspective(@Nonnull ItemCameraTransforms.TransformType cameraTransformType) {
return PerspectiveMapWrapper.handlePerspective(this, SimpleServiceLocator.cclProxy.getDefaultBlockState(), cameraTransformType);
}
};
}
use of net.minecraftforge.common.property.IExtendedBlockState in project Railcraft by Railcraft.
the class BlockRailcraftWall method getActualState.
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
boolean north = canConnectTo(worldIn, pos.north());
boolean east = canConnectTo(worldIn, pos.east());
boolean south = canConnectTo(worldIn, pos.south());
boolean west = canConnectTo(worldIn, pos.west());
boolean smooth = north && !east && south && !west || !north && east && !south && west;
state = state.withProperty(UP, !smooth || !worldIn.isAirBlock(pos.up())).withProperty(NORTH, north).withProperty(EAST, east).withProperty(SOUTH, south).withProperty(WEST, west);
IExtendedBlockState actState = (IExtendedBlockState) state;
actState = actState.withProperty(Materials.MATERIAL_PROPERTY, MatTools.getMat(worldIn, pos));
return actState;
}
use of net.minecraftforge.common.property.IExtendedBlockState in project TechReborn by TechReborn.
the class RenderFluidPipePart method getQuads.
@Override
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand) {
ArrayList<BakedQuad> list = new ArrayList<>();
BlockFaceUV uv = new BlockFaceUV(new float[] { 0.0F, 0.0F, 16.0F, 16.0F }, 0);
BlockPartFace face = new BlockPartFace(null, 0, "", uv);
double thickness = MultipartFluidPipe.thickness;
double lastThickness = 16 - thickness;
IExtendedBlockState state = (IExtendedBlockState) blockState;
if (side != null) {
return Collections.emptyList();
}
boolean renderedConnection = false;
if (state != null) {
if (state.getValue(MultipartFluidPipe.UP)) {
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness), list, face, ModelRotation.X0_Y0, texture, EnumFacing.UP, faceBakery);
renderedConnection = true;
}
if (state.getValue(MultipartFluidPipe.DOWN)) {
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list, face, ModelRotation.X0_Y0, texture, EnumFacing.DOWN, faceBakery);
renderedConnection = true;
}
if (state.getValue(MultipartFluidPipe.NORTH)) {
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, 0.0, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture, EnumFacing.NORTH, faceBakery);
renderedConnection = true;
}
if (state.getValue(MultipartFluidPipe.SOUTH)) {
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, 16.0), list, face, ModelRotation.X0_Y0, texture, EnumFacing.SOUTH, faceBakery);
renderedConnection = false;
}
if (state.getValue(MultipartFluidPipe.EAST)) {
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, 16, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture, EnumFacing.EAST, faceBakery);
renderedConnection = false;
}
if (state.getValue(MultipartFluidPipe.WEST)) {
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture, EnumFacing.WEST, faceBakery);
renderedConnection = true;
}
if (!renderedConnection) {
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture, null, faceBakery);
}
}
return list;
}
use of net.minecraftforge.common.property.IExtendedBlockState in project TechReborn by TechReborn.
the class RenderCablePart method getQuads.
@Override
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand) {
type = blockState.getValue(CableMultipart.TYPE);
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(type.textureName);
ArrayList<BakedQuad> list = new ArrayList<>();
BlockFaceUV uv = new BlockFaceUV(new float[] { 0.0F, 0.0F, 16.0F, 16.0F }, 0);
BlockPartFace face = new BlockPartFace(null, 0, "", uv);
double thickness = type.cableThickness;
double lastThickness = 16 - thickness;
IExtendedBlockState state = (IExtendedBlockState) blockState;
if (side != null) {
return Collections.emptyList();
}
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture, null, faceBakery);
if (state != null) {
if (state.getValue(CableMultipart.UP)) {
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness), list, face, ModelRotation.X0_Y0, texture, EnumFacing.UP, faceBakery);
}
if (state.getValue(CableMultipart.DOWN)) {
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list, face, ModelRotation.X0_Y0, texture, EnumFacing.DOWN, faceBakery);
}
if (state.getValue(CableMultipart.NORTH)) {
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y90, texture, EnumFacing.NORTH, faceBakery);
}
if (state.getValue(CableMultipart.SOUTH)) {
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y270, texture, EnumFacing.SOUTH, faceBakery);
}
if (state.getValue(CableMultipart.EAST)) {
BakedModelUtils.addCubeToList(new Vecs3dCube(lastThickness, thickness, thickness, 16.0, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture, EnumFacing.EAST, faceBakery);
}
if (state.getValue(CableMultipart.WEST)) {
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture, EnumFacing.WEST, faceBakery);
}
}
return list;
}
use of net.minecraftforge.common.property.IExtendedBlockState in project Immersive-Tech by FerroO2000.
the class BlockITTileProvider method getExtendedState.
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
state = super.getExtendedState(state, world, pos);
if (state instanceof IExtendedBlockState) {
IExtendedBlockState extended = (IExtendedBlockState) state;
TileEntity te = world.getTileEntity(pos);
if (te != null) {
if (te instanceof IConfigurableSides)
for (int i = 0; i < 6; i++) if (extended.getUnlistedNames().contains(IEProperties.SIDECONFIG[i]))
extended = extended.withProperty(IEProperties.SIDECONFIG[i], ((IConfigurableSides) te).getSideConfig(i));
if (te instanceof IAdvancedHasObjProperty)
extended = extended.withProperty(Properties.AnimationProperty, ((IAdvancedHasObjProperty) te).getOBJState());
else if (te instanceof IHasObjProperty)
extended = extended.withProperty(Properties.AnimationProperty, new OBJState(((IHasObjProperty) te).compileDisplayList(), true));
if (te instanceof IDynamicTexture)
extended = extended.withProperty(IEProperties.OBJ_TEXTURE_REMAP, ((IDynamicTexture) te).getTextureReplacements());
if (te instanceof IOBJModelCallback)
extended = extended.withProperty(IOBJModelCallback.PROPERTY, (IOBJModelCallback) te);
if (te.hasCapability(CapabilityShader.SHADER_CAPABILITY, null))
extended = extended.withProperty(CapabilityShader.BLOCKSTATE_PROPERTY, te.getCapability(CapabilityShader.SHADER_CAPABILITY, null));
if (te instanceof IPropertyPassthrough && ((IExtendedBlockState) state).getUnlistedNames().contains(IEProperties.TILEENTITY_PASSTHROUGH))
extended = extended.withProperty(IEProperties.TILEENTITY_PASSTHROUGH, te);
if (te instanceof TileEntityImmersiveConnectable && ((IExtendedBlockState) state).getUnlistedNames().contains(IEProperties.CONNECTIONS))
extended = extended.withProperty(IEProperties.CONNECTIONS, ((TileEntityImmersiveConnectable) te).genConnBlockstate());
}
state = extended;
}
return state;
}
Aggregations