Search in sources :

Example 41 with IExtendedBlockState

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);
        List<BakedQuad> quads = modelCache.get(adapter);
        if (quads == null) {
            IESmartObjModel model = null;
            if (objstate != null)
                model = new IESmartObjModel(baseModel, getModel(), objstate, getFormat(), getTextures(), transformationMap, isDynamic);
            if (model == null)
                model = new IESmartObjModel(baseModel, getModel(), this.getState(), getFormat(), getTextures(), transformationMap, isDynamic);
            model.tempState = blockState;
            model.texReplace = tex;
            quads = model.buildQuads();
            modelCache.put(adapter, quads);
        }
        return Collections.synchronizedList(Lists.newArrayList(quads));
    }
    if (bakedQuads == null)
        bakedQuads = buildQuads();
    List<BakedQuad> quadList = Lists.newArrayList(bakedQuads);
    return Collections.synchronizedList(quadList);
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ExtBlockstateAdapter(blusunrize.immersiveengineering.client.models.smart.ConnModelReal.ExtBlockstateAdapter) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState)

Example 42 with IExtendedBlockState

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;
    IConveyorBelt conveyor = defaultBelt;
    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 ImmutableList.copyOf(cachedQuads);
    else {
        if (conveyor == null)
            conveyor = ConveyorHandler.getConveyor(new ResourceLocation(key), tile);
        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, ImmutableList.copyOf(cachedQuads));
        return ImmutableList.copyOf(cachedQuads);
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) IConveyorBelt(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt) Matrix4(blusunrize.immersiveengineering.common.util.chickenbones.Matrix4) TileEntity(net.minecraft.tileentity.TileEntity) Matrix4f(javax.vecmath.Matrix4f) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ResourceLocation(net.minecraft.util.ResourceLocation) ConveyorDirection(blusunrize.immersiveengineering.api.tool.ConveyorHandler.ConveyorDirection)

Example 43 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.

the class ConnModelReal method getQuads.

@Nonnull
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    if (side == null && state instanceof IExtendedBlockState) {
        IExtendedBlockState ext = (IExtendedBlockState) state;
        Object[] additional = null;
        if (ext.getUnlistedProperties().containsKey(IEProperties.TILEENTITY_PASSTHROUGH)) {
            TileEntity te = ext.getValue(IEProperties.TILEENTITY_PASSTHROUGH);
            if (te instanceof IEBlockInterfaces.ICacheData)
                additional = ((IEBlockInterfaces.ICacheData) te).getCacheData();
        }
        int x = 0, z = 0;
        if (ext.getUnlistedProperties().containsKey(IEProperties.CONNECTIONS)) {
            Set<Connection> conns = ext.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;
            }
        }
        ExtBlockstateAdapter ad = new ExtBlockstateAdapter(ext, null, ExtBlockstateAdapter.ONLY_OBJ_CALLBACK, additional);
        Pair<Byte, ExtBlockstateAdapter> key = new ImmutablePair<>((byte) ((x << 4) | z), ad);
        try {
            IBakedModel ret = cache.get(key, () -> new AssembledBakedModel(ext, textureAtlasSprite, base, layers));
            return ret.getQuads(state, null, rand);
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
    return getBaseQuads(MinecraftForgeClient.getRenderLayer(), state, side, rand);
}
Also used : Connection(blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection) TileEntity(net.minecraft.tileentity.TileEntity) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ExecutionException(java.util.concurrent.ExecutionException) Nonnull(javax.annotation.Nonnull)

Example 44 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project Charset by CharsetMC.

the class RendererWire method getGeneralQuads.

@Override
public List<BakedQuad> getGeneralQuads() {
    List<BakedQuad> quads = new ArrayList<BakedQuad>();
    PartWireBase wire = null;
    if (state instanceof IExtendedBlockState) {
        wire = ((IExtendedBlockState) state).getValue(PartWireBase.PROPERTY);
    }
    if (wire != null) {
        renderers.get(getRendererId()).handlePartState(state);
        renderers.get(getRendererId()).addWire(wire, wire.location, wire.getRedstoneLevel() > 0, quads);
    } else if (stack != null) {
        if (ItemWire.isFreestanding(stack)) {
            renderers.get(getRendererId()).handleItemState(stack);
            renderers.get(getRendererId()).addWireFreestanding(null, false, quads);
        } else {
            renderers.get(getRendererId()).handleItemState(stack);
            renderers.get(getRendererId()).addWire(null, WireFace.DOWN, false, quads);
        }
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) PartWireBase(pl.asie.charset.wires.logic.PartWireBase) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ArrayList(java.util.ArrayList)

Example 45 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project Immersive-Tech by FerroO2000.

the class BlockConnectors 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)

Aggregations

IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)98 IBlockState (net.minecraft.block.state.IBlockState)29 BlockPos (net.minecraft.util.math.BlockPos)25 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 IBlockAccess (net.minecraft.world.IBlockAccess)14 ArrayList (java.util.ArrayList)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 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 Minecraft (net.minecraft.client.Minecraft)3