Search in sources :

Example 76 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project Random-Things by lumien231.

the class ModelCustomWorkbench method getQuads.

@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
    checkDefault();
    IBakedModel model = defaultModel;
    IExtendedBlockState extendedState = (IExtendedBlockState) state;
    IBlockState woodState = extendedState.getValue(BlockCustomWorkbench.WOOD_STATE);
    if (woodState != null) {
        if (modelCache.containsKey(woodState)) {
            model = modelCache.get(woodState);
        } else {
            modelCache.put(woodState, new ModelCubeOverlay(RenderUtils.getQuadFaceMapFromState(woodState), overlays, Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(Blocks.PLANKS.getDefaultState()).getParticleTexture(), true));
            model = modelCache.get(woodState);
        }
    }
    return model.getQuads(woodState, side, rand);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemOverride(net.minecraft.client.renderer.block.model.ItemOverride)

Example 77 with IExtendedBlockState

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

the class BlockConveyor 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 TileEntityConveyorBelt))
            return state;
        state = ext.withProperty(ICONEYOR_PASSTHROUGH, ((TileEntityConveyorBelt) te).getConveyorSubtype());
    }
    return state;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState)

Example 78 with IExtendedBlockState

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

the class FeedthroughModel method getQuads.

@Nonnull
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    IBlockState baseState = Blocks.STONE.getDefaultState();
    WireType wire = WireType.COPPER;
    EnumFacing facing = EnumFacing.NORTH;
    int offset = 1;
    BlockPos p = null;
    World w = null;
    if (state instanceof IExtendedBlockState) {
        TileEntity te = ((IExtendedBlockState) state).getValue(IEProperties.TILEENTITY_PASSTHROUGH);
        if (te instanceof TileEntityFeedthrough) {
            baseState = ((TileEntityFeedthrough) te).stateForMiddle;
            wire = ((TileEntityFeedthrough) te).reference;
            facing = ((TileEntityFeedthrough) te).getFacing();
            offset = ((TileEntityFeedthrough) te).offset;
            p = te.getPos();
            w = te.getWorld();
        }
    }
    final BlockPos pFinal = p;
    final World wFinal = w;
    FeedthroughCacheKey key = new FeedthroughCacheKey(wire, baseState, offset, facing, MinecraftForgeClient.getRenderLayer());
    try {
        return CACHE.get(key, () -> new SpecificFeedthroughModel(key, wFinal, pFinal)).getQuads(state, side, rand);
    } catch (ExecutionException e) {
        e.printStackTrace();
        return ImmutableList.of();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) EnumFacing(net.minecraft.util.EnumFacing) TileEntityFeedthrough(blusunrize.immersiveengineering.common.blocks.metal.TileEntityFeedthrough) BlockPos(net.minecraft.util.math.BlockPos) WireType(blusunrize.immersiveengineering.api.energy.wires.WireType) World(net.minecraft.world.World) ExecutionException(java.util.concurrent.ExecutionException) Nonnull(javax.annotation.Nonnull)

Example 79 with IExtendedBlockState

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

the class IESmartObjModel method buildQuads.

private ImmutableList<BakedQuad> buildQuads() {
    List<BakedQuad> quads = Lists.newArrayList();
    ItemStack shader = ItemStack.EMPTY;
    ShaderCase sCase = null;
    IOBJModelCallback callback = null;
    Object callbackObject = null;
    if (!this.tempStack.isEmpty() && tempStack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) {
        ShaderWrapper wrapper = tempStack.getCapability(CapabilityShader.SHADER_CAPABILITY, null);
        if (wrapper != null) {
            shader = wrapper.getShaderItem();
            if (!shader.isEmpty() && shader.getItem() instanceof IShaderItem)
                sCase = ((IShaderItem) shader.getItem()).getShaderCase(shader, tempStack, wrapper.getShaderType());
        }
    } else if (this.tempState != null && this.tempState instanceof IExtendedBlockState && ((IExtendedBlockState) this.tempState).getUnlistedNames().contains(CapabilityShader.BLOCKSTATE_PROPERTY)) {
        ShaderWrapper wrapper = ((IExtendedBlockState) this.tempState).getValue(CapabilityShader.BLOCKSTATE_PROPERTY);
        if (wrapper != null) {
            shader = wrapper.getShaderItem();
            if (!shader.isEmpty() && shader.getItem() instanceof IShaderItem)
                sCase = ((IShaderItem) shader.getItem()).getShaderCase(shader, null, wrapper.getShaderType());
        }
    }
    if (!this.tempStack.isEmpty() && tempStack.getItem() instanceof IOBJModelCallback) {
        callback = (IOBJModelCallback) tempStack.getItem();
        callbackObject = this.tempStack;
    } else if (this.tempState != null && this.tempState instanceof IExtendedBlockState && ((IExtendedBlockState) this.tempState).getUnlistedNames().contains(IOBJModelCallback.PROPERTY)) {
        callback = ((IExtendedBlockState) this.tempState).getValue(IOBJModelCallback.PROPERTY);
        callbackObject = this.tempState;
    }
    for (String groupName : getModel().getMatLib().getGroups().keySet()) {
        List<Pair<BakedQuad, ShaderLayer>> temp = addQuadsForGroup(callback, callbackObject, groupName, sCase, shader);
        quads.addAll(temp.stream().filter(Objects::nonNull).map(Pair::getKey).collect(Collectors.toList()));
    }
    if (callback != null)
        quads = callback.modifyQuads(callbackObject, quads);
    return ImmutableList.copyOf(quads);
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IShaderItem(blusunrize.immersiveengineering.api.shader.IShaderItem) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ShaderCase(blusunrize.immersiveengineering.api.shader.ShaderCase) ShaderWrapper(blusunrize.immersiveengineering.api.shader.CapabilityShader.ShaderWrapper) ItemStack(net.minecraft.item.ItemStack) ComparableItemStack(blusunrize.immersiveengineering.api.ComparableItemStack) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

Example 80 with IExtendedBlockState

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

the class ModelConfigurableSides method getQuads.

@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    TextureAtlasSprite[] tex = new TextureAtlasSprite[6];
    for (int i = 0; i < tex.length; i++) tex[i] = this.textures[i][0];
    char[] keyArray = "000000".toCharArray();
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState extended = (IExtendedBlockState) state;
        for (int i = 0; i < IEProperties.SIDECONFIG.length; i++) if (extended.getUnlistedNames().contains(IEProperties.SIDECONFIG[i])) {
            IEEnums.SideConfig config = extended.getValue(IEProperties.SIDECONFIG[i]);
            if (config != null) {
                int c = config.ordinal();
                tex[i] = this.textures[i][c];
                keyArray[i] = Character.forDigit(c, 10);
            }
        }
    }
    String key = name + String.copyValueOf(keyArray);
    if (!modelCache.containsKey(key))
        modelCache.put(key, bakeQuads(tex));
    return modelCache.get(key);
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) SideConfig(blusunrize.immersiveengineering.api.IEEnums.SideConfig)

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