Search in sources :

Example 1 with IRotationProvider

use of logisticspipes.interfaces.IRotationProvider in project LogisticsPipes by RS485.

the class LogisticsBlockGenericPipe method getActualState.

@Nonnull
@Override
public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) {
    checkForRenderChanges(worldIn, pos);
    state = super.getActualState(state, worldIn, pos);
    CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(worldIn, pos);
    if (LogisticsBlockGenericPipe.isValid(pipe)) {
        if (pipe instanceof IRotationProvider) {
            state = state.withProperty(rotationProperty, ((IRotationProvider) pipe).getRotation());
        }
        for (EnumFacing side : EnumFacing.VALUES) {
            state = state.withProperty(connectionPropertys.get(side), pipe.container.renderState.pipeConnectionMatrix.isConnected(side));
        }
        if (pipe instanceof PipeBlockRequestTable) {
            state = state.withProperty(modelTypeProperty, PipeRenderModel.REQUEST_TABLE);
        }
    }
    return state;
}
Also used : IRotationProvider(logisticspipes.interfaces.IRotationProvider) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) EnumFacing(net.minecraft.util.EnumFacing) Nonnull(javax.annotation.Nonnull)

Example 2 with IRotationProvider

use of logisticspipes.interfaces.IRotationProvider in project LogisticsPipes by RS485.

the class LogisticsSolidBlock method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, @Nonnull ItemStack stack) {
    super.onBlockPlacedBy(world, pos, state, placer, stack);
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof LogisticsCraftingTableTileEntity) {
        ((LogisticsCraftingTableTileEntity) tile).placedBy(placer);
    }
    if (tile instanceof IRotationProvider) {
        ((IRotationProvider) tile).setFacing(placer.getHorizontalFacing().getOpposite());
    }
}
Also used : LogisticsRFPowerProviderTileEntity(logisticspipes.blocks.powertile.LogisticsRFPowerProviderTileEntity) LogisticsPowerJunctionTileEntity(logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity) IGuiTileEntity(logisticspipes.interfaces.IGuiTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity) LogisticsIC2PowerProviderTileEntity(logisticspipes.blocks.powertile.LogisticsIC2PowerProviderTileEntity) LogisticsStatisticsTileEntity(logisticspipes.blocks.stats.LogisticsStatisticsTileEntity) IRotationProvider(logisticspipes.interfaces.IRotationProvider) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity)

Example 3 with IRotationProvider

use of logisticspipes.interfaces.IRotationProvider in project LogisticsPipes by RS485.

the class LogisticsSolidBlock method getIcon.

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess access, int x, int y, int z, int side) {
    int meta = access.getBlockMetadata(x, y, z);
    TileEntity tile = access.getTileEntity(x, y, z);
    if (tile instanceof IRotationProvider) {
        return getRotatedTexture(meta, side, ((IRotationProvider) tile).getRotation(), ((IRotationProvider) tile).getFrontTexture());
    } else {
        return getRotatedTexture(meta, side, 3, 0);
    }
}
Also used : LogisticsRFPowerProviderTileEntity(logisticspipes.blocks.powertile.LogisticsRFPowerProviderTileEntity) LogisticsPowerJunctionTileEntity(logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity) IGuiTileEntity(logisticspipes.interfaces.IGuiTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity) LogisticsIC2PowerProviderTileEntity(logisticspipes.blocks.powertile.LogisticsIC2PowerProviderTileEntity) LogisticsStatisticsTileEntity(logisticspipes.blocks.stats.LogisticsStatisticsTileEntity) IRotationProvider(logisticspipes.interfaces.IRotationProvider) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 4 with IRotationProvider

use of logisticspipes.interfaces.IRotationProvider in project LogisticsPipes by RS485.

the class LogisticsSolidBlock method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, int posX, int posY, int posZ, EntityLivingBase entity, ItemStack itemStack) {
    super.onBlockPlacedBy(world, posX, posY, posZ, entity, itemStack);
    TileEntity tile = world.getTileEntity(posX, posY, posZ);
    if (tile instanceof LogisticsCraftingTableTileEntity) {
        ((LogisticsCraftingTableTileEntity) tile).placedBy(entity);
    }
    if (tile instanceof IRotationProvider) {
        double x = tile.xCoord + 0.5 - entity.posX;
        double z = tile.zCoord + 0.5 - entity.posZ;
        double w = Math.atan2(x, z);
        double halfPI = Math.PI / 2;
        double halfhalfPI = halfPI / 2;
        w -= halfhalfPI;
        if (w < 0) {
            w += 2 * Math.PI;
        }
        if (0 < w && w <= halfPI) {
            ((IRotationProvider) tile).setRotation(1);
        } else if (halfPI < w && w <= 2 * halfPI) {
            ((IRotationProvider) tile).setRotation(2);
        } else if (2 * halfPI < w && w <= 3 * halfPI) {
            ((IRotationProvider) tile).setRotation(0);
        } else if (3 * halfPI < w && w <= 4 * halfPI) {
            ((IRotationProvider) tile).setRotation(3);
        }
    }
}
Also used : LogisticsRFPowerProviderTileEntity(logisticspipes.blocks.powertile.LogisticsRFPowerProviderTileEntity) LogisticsPowerJunctionTileEntity(logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity) IGuiTileEntity(logisticspipes.interfaces.IGuiTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity) LogisticsIC2PowerProviderTileEntity(logisticspipes.blocks.powertile.LogisticsIC2PowerProviderTileEntity) LogisticsStatisticsTileEntity(logisticspipes.blocks.stats.LogisticsStatisticsTileEntity) IRotationProvider(logisticspipes.interfaces.IRotationProvider) LogisticsCraftingTableTileEntity(logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity)

Example 5 with IRotationProvider

use of logisticspipes.interfaces.IRotationProvider in project LogisticsPipes by RS485.

the class Rotation method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    IRotationProvider tile = this.getTileOrPipe(player.world, IRotationProvider.class);
    if (tile != null) {
        tile.setRotation(getInteger());
        player.world.notifyNeighborsRespectDebug(new BlockPos(getPosX(), getPosY(), getPosZ()), player.world.getBlockState(new BlockPos(getPosX(), getPosY(), getPosZ())).getBlock(), true);
    }
}
Also used : IRotationProvider(logisticspipes.interfaces.IRotationProvider) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

IRotationProvider (logisticspipes.interfaces.IRotationProvider)5 LogisticsCraftingTableTileEntity (logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity)3 LogisticsIC2PowerProviderTileEntity (logisticspipes.blocks.powertile.LogisticsIC2PowerProviderTileEntity)3 LogisticsPowerJunctionTileEntity (logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity)3 LogisticsRFPowerProviderTileEntity (logisticspipes.blocks.powertile.LogisticsRFPowerProviderTileEntity)3 LogisticsStatisticsTileEntity (logisticspipes.blocks.stats.LogisticsStatisticsTileEntity)3 IGuiTileEntity (logisticspipes.interfaces.IGuiTileEntity)3 TileEntity (net.minecraft.tileentity.TileEntity)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 Nonnull (javax.annotation.Nonnull)1 PipeBlockRequestTable (logisticspipes.pipes.PipeBlockRequestTable)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1