Search in sources :

Example 1 with IConveyorBelt

use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt in project ImmersiveEngineering by BluSunrize.

the class BlockConveyor method onIEBlockPlacedBy.

@Override
public void onIEBlockPlacedBy(World world, BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase placer, ItemStack stack) {
    super.onIEBlockPlacedBy(world, pos, state, side, hitX, hitY, hitZ, placer, stack);
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityConveyorBelt && !(tile instanceof TileEntityConveyorVertical)) {
        TileEntityConveyorBelt conveyor = (TileEntityConveyorBelt) tile;
        EnumFacing f = conveyor.facing;
        ResourceLocation rl = new ResourceLocation(ItemNBTHelper.getString(stack, "conveyorType"));
        IConveyorBelt subType = ConveyorHandler.getConveyor(rl, conveyor);
        conveyor.setConveyorSubtype(subType);
        tile = world.getTileEntity(pos.offset(f));
        TileEntity tileUp = world.getTileEntity(pos.offset(f).add(0, 1, 0));
        if (subType != null && (!(tile instanceof IConveyorTile) || ((IConveyorTile) tile).getFacing() == f.getOpposite()) && tileUp instanceof IConveyorTile && ((IConveyorTile) tileUp).getFacing() != f.getOpposite() && world.isAirBlock(pos.add(0, 1, 0)))
            subType.setConveyorDirection(ConveyorDirection.UP);
        tile = world.getTileEntity(pos.offset(f.getOpposite()).add(0, 1, 0));
    // if(tile instanceof TileEntityConveyorBelt&&!(tile instanceof TileEntityConveyorVertical) && ((TileEntityConveyorBelt)tile).facing==f)
    // conveyor.transportDown = true;
    // if(conveyor.transportUp && conveyor.transportDown)
    // conveyor.transportDown = false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) ResourceLocation(net.minecraft.util.ResourceLocation) IConveyorBelt(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt) IConveyorTile(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile)

Example 2 with IConveyorBelt

use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt 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 3 with IConveyorBelt

use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt in project ImmersiveEngineering by BluSunrize.

the class TileEntityConveyorBelt method readOnPlacement.

@Override
public void readOnPlacement(EntityLivingBase placer, ItemStack stack) {
    String key = ItemNBTHelper.getString(stack, "conveyorType");
    IConveyorBelt subType = ConveyorHandler.getConveyor(new ResourceLocation(key), this);
    setConveyorSubtype(subType);
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) IConveyorBelt(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt)

Example 4 with IConveyorBelt

use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt in project ImmersiveEngineering by BluSunrize.

the class ConveyorVertical method isInwardConveyor.

protected boolean isInwardConveyor(TileEntity tile, EnumFacing f) {
    TileEntity te = tile.getWorld().getTileEntity(tile.getPos().offset(f));
    if (te instanceof IConveyorTile) {
        IConveyorBelt sub = ((IConveyorTile) te).getConveyorSubtype();
        if (sub != null)
            for (EnumFacing f2 : sub.sigTransportDirections(te, ((IConveyorTile) te).getFacing())) if (f2 == EnumFacing.UP)
                break;
            else if (f == f2.getOpposite())
                return true;
    }
    te = tile.getWorld().getTileEntity(tile.getPos().add(0, -1, 0).offset(f));
    if (te instanceof IConveyorTile) {
        IConveyorBelt sub = ((IConveyorTile) te).getConveyorSubtype();
        if (sub != null) {
            int b = 0;
            for (EnumFacing f2 : sub.sigTransportDirections(te, ((IConveyorTile) te).getFacing())) {
                if (f == f2.getOpposite())
                    b++;
                else if (EnumFacing.UP == f2)
                    b++;
                if (b == 2)
                    return true;
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) IConveyorBelt(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt) IConveyorTile(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile)

Example 5 with IConveyorBelt

use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt in project ImmersiveEngineering by BluSunrize.

the class ClientProxy method drawConveyorInGui.

@Override
public boolean drawConveyorInGui(String conveyor, EnumFacing facing) {
    IConveyorBelt con = ConveyorHandler.getConveyor(new ResourceLocation(conveyor), null);
    if (con != null) {
        GlStateManager.pushMatrix();
        List<BakedQuad> quads = ModelConveyor.getBaseConveyor(facing, 1, new Matrix4(facing), ConveyorDirection.HORIZONTAL, ClientUtils.getSprite(con.getActiveTexture()), new boolean[] { true, true }, new boolean[] { true, true }, null, 0);
        // GlStateManager.translate(0, 0, 1);
        ClientUtils.renderQuads(quads, 1, 1, 1, 1);
        GlStateManager.popMatrix();
        return true;
    }
    return false;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IConveyorBelt(blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt) Matrix4(blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)

Aggregations

IConveyorBelt (blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt)6 ResourceLocation (net.minecraft.util.ResourceLocation)4 TileEntity (net.minecraft.tileentity.TileEntity)3 EnumFacing (net.minecraft.util.EnumFacing)3 IConveyorTile (blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorTile)2 Matrix4 (blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)2 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)2 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)2 ConveyorDirection (blusunrize.immersiveengineering.api.tool.ConveyorHandler.ConveyorDirection)1 ModelConveyor (blusunrize.immersiveengineering.client.models.ModelConveyor)1 ModelCoresample (blusunrize.immersiveengineering.client.models.ModelCoresample)1 FeedthroughModel (blusunrize.immersiveengineering.client.models.smart.FeedthroughModel)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Matrix4f (javax.vecmath.Matrix4f)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1