use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class BlockConnector method getExtendedState.
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
state = super.getExtendedState(state, world, pos);
if (state instanceof IExtendedBlockState) {
IExtendedBlockState ext = (IExtendedBlockState) state;
TileEntity te = world.getTileEntity(pos);
if (!(te instanceof TileEntityImmersiveConnectable))
return state;
state = ext.withProperty(IEProperties.CONNECTIONS, ((TileEntityImmersiveConnectable) te).genConnBlockstate());
}
return state;
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class ClientProxy method drawSpecificFluidPipe.
@Override
public void drawSpecificFluidPipe(String configuration) {
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBlockState state = IEContent.blockMetalDevice1.getStateFromMeta(BlockTypes_MetalDevice1.FLUID_PIPE.getMeta());
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
if (state instanceof IExtendedBlockState)
state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, TileEntityFluidPipe.getStateFromKey(configuration));
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0, 1);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
// if(model instanceof ISmartBlockModel)
// model = ((ISmartBlockModel) model).handleBlockState(state);
blockRenderer.getBlockModelRenderer().renderModelBrightness(model, state, .75f, false);
GlStateManager.popMatrix();
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class Utils method areStatesEqual.
public static boolean areStatesEqual(IBlockState state, IBlockState other, Set<Object> ignoredProperties, boolean includeExtended) {
for (IProperty<?> i : state.getPropertyKeys()) {
if (!other.getProperties().containsKey(i))
return false;
if (ignoredProperties.contains(i))
continue;
Object valThis = state.getValue(i);
Object valOther = other.getValue(i);
if (valThis == null && valOther == null)
continue;
else if (valOther == null || !valOther.equals(state.getValue(i)))
return false;
}
if (includeExtended) {
if (state instanceof IExtendedBlockState ^ other instanceof IExtendedBlockState)
return false;
if (state instanceof IExtendedBlockState) {
IExtendedBlockState extState = (IExtendedBlockState) state;
IExtendedBlockState extOther = (IExtendedBlockState) other;
for (IUnlistedProperty<?> i : extState.getUnlistedNames()) {
if (!extOther.getUnlistedProperties().containsKey(i))
return false;
if (ignoredProperties.contains(i))
continue;
Object valThis = extState.getValue(i);
Object valOther = extOther.getValue(i);
if (i == IEProperties.CONNECTIONS) {
if (!areRenderConnectionsEqual((Set<Connection>) valThis, (Set<Connection>) valOther))
return false;
} else if (valThis == null && valOther == null)
continue;
else if (valOther == null || !valOther.equals(valThis))
return false;
}
}
}
return true;
}
use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.
the class Utils method hashBlockstate.
public static int hashBlockstate(IBlockState state, Set<Object> ignoredProperties, boolean includeExtended) {
int val = 0;
final int prime = 31;
for (IProperty<?> n : state.getPropertyKeys()) if (!ignoredProperties.contains(n)) {
Object o = state.getValue(n);
val = prime * val + (o == null ? 0 : o.hashCode());
}
if (includeExtended && state instanceof IExtendedBlockState) {
IExtendedBlockState ext = (IExtendedBlockState) state;
for (IUnlistedProperty<?> n : ext.getUnlistedNames()) if (!ignoredProperties.contains(n)) {
Object o = ext.getValue(n);
val = prime * val + (o == null ? 0 : o.hashCode());
}
}
return val;
}
use of net.minecraftforge.common.property.IExtendedBlockState in project LogisticsPipes by RS485.
the class LogisticsNewPipeModel method generatePipeRenderList.
private List<RenderEntry> generatePipeRenderList(IBlockState blockstate) {
List<RenderEntry> objectsToRender = new ArrayList<>();
if (blockstate.getValue(LogisticsBlockGenericPipe.modelTypeProperty) == LogisticsBlockGenericPipe.PipeRenderModel.REQUEST_TABLE) {
TextureTransformation icon = SimpleServiceLocator.cclProxy.createIconTransformer((TextureAtlasSprite) Textures.LOGISTICS_REQUEST_TABLE_NEW);
LogisticsNewSolidBlockWorldRenderer.BlockRotation rotation = LogisticsNewSolidBlockWorldRenderer.BlockRotation.getRotation(blockstate.getValue(LogisticsBlockGenericPipe.rotationProperty));
// Draw
objectsToRender.add(new RenderEntry(LogisticsNewSolidBlockWorldRenderer.block.get(rotation), icon));
for (LogisticsNewSolidBlockWorldRenderer.CoverSides side : LogisticsNewSolidBlockWorldRenderer.CoverSides.values()) {
if (!blockstate.getValue(LogisticsBlockGenericPipe.connectionPropertys.get(side.getDir(rotation)))) {
objectsToRender.add(new RenderEntry(LogisticsNewSolidBlockWorldRenderer.texturePlate_Outer.get(side).get(rotation), icon));
}
}
} else if (blockstate instanceof IExtendedBlockState) {
IExtendedBlockState lpState = (IExtendedBlockState) blockstate;
objectsToRender = lpState.getValue(LogisticsBlockGenericPipe.propertyRenderList);
}
if (objectsToRender != null) {
return objectsToRender;
} else {
return Collections.emptyList();
}
}
Aggregations