Search in sources :

Example 86 with IExtendedBlockState

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityImmersiveConnectable(blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState)

Example 87 with IExtendedBlockState

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();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 88 with IExtendedBlockState

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;
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState)

Example 89 with IExtendedBlockState

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;
}
Also used : IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState)

Example 90 with IExtendedBlockState

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();
    }
}
Also used : TextureTransformation(logisticspipes.proxy.object3d.interfaces.TextureTransformation) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ArrayList(java.util.ArrayList)

Aggregations

IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)96 IBlockState (net.minecraft.block.state.IBlockState)27 BlockPos (net.minecraft.util.math.BlockPos)24 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)17 EnumFacing (net.minecraft.util.EnumFacing)17 OBJState (net.minecraftforge.client.model.obj.OBJModel.OBJState)17 TileEntity (net.minecraft.tileentity.TileEntity)16 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)14 ArrayList (java.util.ArrayList)13 IBlockAccess (net.minecraft.world.IBlockAccess)13 UnlistedBlockPos (forestry.core.blocks.properties.UnlistedBlockPos)10 TileEntityImmersiveConnectable (blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable)7 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)7 Block (net.minecraft.block.Block)6 ItemStack (net.minecraft.item.ItemStack)6 Nonnull (javax.annotation.Nonnull)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 Minecraft (net.minecraft.client.Minecraft)3 Vec3d (net.minecraft.util.math.Vec3d)3