Search in sources :

Example 1 with TileEntityOredictionificator

use of mekanism.common.tile.machine.TileEntityOredictionificator in project Mekanism by mekanism.

the class PacketEditFilter method handle.

@Override
public void handle(NetworkEvent.Context context) {
    PlayerEntity player = context.getSender();
    if (player == null) {
        return;
    }
    TileEntity tile = WorldUtils.getTileEntity(player.level, pos);
    if (tile != null) {
        if (filter instanceof SorterFilter && tile instanceof TileEntityLogisticalSorter) {
            HashList<SorterFilter<?>> filters = ((TileEntityLogisticalSorter) tile).getFilters();
            int index = filters.indexOf(filter);
            if (index != -1) {
                filters.remove(index);
                if (!delete) {
                    filters.add(index, (SorterFilter<?>) edited);
                }
            }
        } else if (filter instanceof MinerFilter && tile instanceof TileEntityDigitalMiner) {
            HashList<MinerFilter<?>> filters = ((TileEntityDigitalMiner) tile).getFilters();
            int index = filters.indexOf(filter);
            if (index != -1) {
                filters.remove(index);
                if (!delete) {
                    filters.add(index, (MinerFilter<?>) edited);
                }
            }
        } else if (filter instanceof OredictionificatorItemFilter && tile instanceof TileEntityOredictionificator) {
            HashList<OredictionificatorItemFilter> filters = ((TileEntityOredictionificator) tile).getFilters();
            int index = filters.indexOf(filter);
            if (index != -1) {
                filters.remove(index);
                if (!delete) {
                    filters.add(index, (OredictionificatorItemFilter) edited);
                }
            }
        } else if (filter instanceof QIOFilter && tile instanceof TileEntityQIOFilterHandler) {
            HashList<QIOFilter<?>> filters = ((TileEntityQIOFilterHandler) tile).getFilters();
            int index = filters.indexOf(filter);
            if (index != -1) {
                filters.remove(index);
                if (!delete) {
                    filters.add(index, (QIOFilter<?>) edited);
                }
            }
        }
        tile.setChanged();
    }
}
Also used : SorterFilter(mekanism.common.content.transporter.SorterFilter) HashList(mekanism.common.lib.collection.HashList) TileEntityLogisticalSorter(mekanism.common.tile.TileEntityLogisticalSorter) MinerFilter(mekanism.common.content.miner.MinerFilter) PlayerEntity(net.minecraft.entity.player.PlayerEntity) TileEntityOredictionificator(mekanism.common.tile.machine.TileEntityOredictionificator) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityDigitalMiner(mekanism.common.tile.machine.TileEntityDigitalMiner) TileEntityQIOFilterHandler(mekanism.common.tile.qio.TileEntityQIOFilterHandler) QIOFilter(mekanism.common.content.qio.filter.QIOFilter) OredictionificatorItemFilter(mekanism.common.content.oredictionificator.OredictionificatorItemFilter)

Aggregations

MinerFilter (mekanism.common.content.miner.MinerFilter)1 OredictionificatorItemFilter (mekanism.common.content.oredictionificator.OredictionificatorItemFilter)1 QIOFilter (mekanism.common.content.qio.filter.QIOFilter)1 SorterFilter (mekanism.common.content.transporter.SorterFilter)1 HashList (mekanism.common.lib.collection.HashList)1 TileEntityLogisticalSorter (mekanism.common.tile.TileEntityLogisticalSorter)1 TileEntityDigitalMiner (mekanism.common.tile.machine.TileEntityDigitalMiner)1 TileEntityOredictionificator (mekanism.common.tile.machine.TileEntityOredictionificator)1 TileEntityQIOFilterHandler (mekanism.common.tile.qio.TileEntityQIOFilterHandler)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 TileEntity (net.minecraft.tileentity.TileEntity)1