Search in sources :

Example 1 with IServerConduit

use of crazypants.enderio.base.conduit.IServerConduit in project EnderIO by SleepyTrousers.

the class AbstractConduit method onAfterRemovedFromBundle.

@Override
public void onAfterRemovedFromBundle() {
    TileEntity te = getBundle().getEntity();
    World world = te.getWorld();
    for (EnumFacing dir : conduitConnections) {
        IConduit neighbour = ConduitUtil.getConduit(world, te, dir, getBaseConduitType());
        if (neighbour instanceof IServerConduit) {
            ((IServerConduit) neighbour).conduitConnectionRemoved(dir.getOpposite());
            ((IServerConduit) neighbour).connectionsChanged();
        }
    }
    conduitConnections.clear();
    if (!externalConnections.isEmpty()) {
        world.notifyNeighborsOfStateChange(te.getPos(), te.getBlockType(), true);
    }
    externalConnections.clear();
    IConduitNetwork<?, ?> network = getNetwork();
    if (network != null) {
        network.destroyNetwork();
    }
    connectionsChanged();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IServerConduit(crazypants.enderio.base.conduit.IServerConduit) EnumFacing(net.minecraft.util.EnumFacing) IConduit(crazypants.enderio.base.conduit.IConduit) World(net.minecraft.world.World)

Example 2 with IServerConduit

use of crazypants.enderio.base.conduit.IServerConduit in project EnderIO by SleepyTrousers.

the class AdvancedLiquidConduitNetwork method updateActiveState.

private void updateActiveState() {
    boolean isActive = tank.containsValidLiquid() && !tank.isEmpty();
    if (!isActive) {
        if (!fluidTypeLocked && liquidType != null) {
            ticksEmpty++;
            if (ticksEmpty > 40) {
                setFluidType(null);
                ticksEmpty = 0;
                for (IServerConduit con : getConduits()) {
                    con.setActive(false);
                }
                lastSyncedActive = false;
            }
        }
        return;
    }
    ticksEmpty = 0;
    if (!lastSyncedActive) {
        for (IServerConduit con : getConduits()) {
            con.setActive(true);
        }
        lastSyncedActive = true;
    }
}
Also used : IServerConduit(crazypants.enderio.base.conduit.IServerConduit)

Example 3 with IServerConduit

use of crazypants.enderio.base.conduit.IServerConduit in project EnderIO by SleepyTrousers.

the class ItemConduitProbe method copyPasteSettings.

public static boolean copyPasteSettings(@Nonnull EntityPlayer player, @Nonnull ItemStack stack, @Nonnull IConduitBundle bundle, @Nonnull EnumFacing dir) {
    if (player.world.isRemote) {
        return true;
    }
    boolean isCopy = player.isSneaking();
    boolean clearedData = false;
    if (!isCopy && !stack.hasTagCompound()) {
        return false;
    }
    boolean performedAction = false;
    Collection<IServerConduit> conduits = bundle.getServerConduits();
    for (IServerConduit conduit : conduits) {
        if (conduit.getExternalConnections().contains(dir)) {
            if (isCopy && !clearedData) {
                clearedData = true;
            }
            if (isCopy) {
                NBTTagCompound nbt = new NBTTagCompound();
                performedAction |= conduit.writeConnectionSettingsToNBT(dir, nbt);
                stack.setTagCompound(nbt);
            } else {
                NBTTagCompound nbt = stack.getTagCompound();
                performedAction |= nbt != null && conduit.readConduitSettingsFromNBT(dir, nbt);
            }
        }
    }
    if (isCopy && performedAction) {
        player.sendStatusMessage(Lang.GUI_PROBE_COPIED.toChatServer(), true);
    }
    return performedAction;
}
Also used : IServerConduit(crazypants.enderio.base.conduit.IServerConduit) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 4 with IServerConduit

use of crazypants.enderio.base.conduit.IServerConduit in project EnderIO by SleepyTrousers.

the class AbstractConduit method onAddedToBundle.

@Override
public void onAddedToBundle() {
    TileEntity te = bundle.getEntity();
    World world = te.getWorld();
    conduitConnections.clear();
    for (EnumFacing dir : EnumFacing.VALUES) {
        IConduit neighbour = ConduitUtil.getConduit(world, te, dir, getBaseConduitType());
        if (neighbour instanceof IServerConduit && ((IServerConduit) neighbour).canConnectToConduit(dir.getOpposite(), this)) {
            conduitConnections.add(dir);
            ((IServerConduit) neighbour).conduitConnectionAdded(dir.getOpposite());
            ((IServerConduit) neighbour).connectionsChanged();
        }
    }
    externalConnections.clear();
    for (EnumFacing dir : EnumFacing.VALUES) {
        if (!containsConduitConnection(dir) && canConnectToExternal(dir, false)) {
            externalConnectionAdded(dir);
        }
    }
    connectionsChanged();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IServerConduit(crazypants.enderio.base.conduit.IServerConduit) EnumFacing(net.minecraft.util.EnumFacing) IConduit(crazypants.enderio.base.conduit.IConduit) World(net.minecraft.world.World)

Example 5 with IServerConduit

use of crazypants.enderio.base.conduit.IServerConduit in project EnderIO by SleepyTrousers.

the class ConduitHandler method store.

@Override
public boolean store(@Nonnull Registry registry, @Nonnull Set<NBTAction> phase, @Nonnull NBTTagCompound nbt, @Nonnull String name, @Nonnull IConduit object) throws IllegalArgumentException, IllegalAccessException, InstantiationException, NoHandlerFoundException {
    if (object instanceof IServerConduit) {
        NBTTagCompound root = new NBTTagCompound();
        ConduitUtil.writeToNBT((IServerConduit) object, root);
        nbt.setTag(name, root);
    } else {
        Log.error("Logic error: Attempting to store client conduit procy as NBT for phase(S) " + phase);
    }
    return true;
}
Also used : IServerConduit(crazypants.enderio.base.conduit.IServerConduit) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

IServerConduit (crazypants.enderio.base.conduit.IServerConduit)8 IConduit (crazypants.enderio.base.conduit.IConduit)4 TileEntity (net.minecraft.tileentity.TileEntity)4 IConduitBundle (crazypants.enderio.base.conduit.IConduitBundle)2 Nonnull (javax.annotation.Nonnull)2 ItemStack (net.minecraft.item.ItemStack)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 EnumFacing (net.minecraft.util.EnumFacing)2 World (net.minecraft.world.World)2 IClientConduit (crazypants.enderio.base.conduit.IClientConduit)1 ConduitCacheKey (crazypants.enderio.conduits.render.BlockStateWrapperConduitBundle.ConduitCacheKey)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 BlockPos (net.minecraft.util.math.BlockPos)1