Search in sources :

Example 1 with PluggableDefinition

use of buildcraft.api.transport.pluggable.PluggableDefinition in project BuildCraft by BuildCraft.

the class ItemPluggableLens method onPlace.

@Override
public PipePluggable onPlace(@Nonnull ItemStack stack, IPipeHolder holder, EnumFacing side, EntityPlayer player, EnumHand hand) {
    IPipe pipe = holder.getPipe();
    if (pipe == null || !(pipe.getFlow() instanceof IFlowItems)) {
        return null;
    }
    LensData data = getData(stack);
    SoundUtil.playBlockPlace(holder.getPipeWorld(), holder.getPipePos(), Blocks.STONE.getDefaultState());
    PluggableDefinition def = BCTransportPlugs.lens;
    return new PluggableLens(def, holder, side, data.colour, data.isFilter);
}
Also used : PluggableLens(buildcraft.transport.plug.PluggableLens) PluggableDefinition(buildcraft.api.transport.pluggable.PluggableDefinition) IFlowItems(buildcraft.api.transport.pipe.IFlowItems) IPipe(buildcraft.api.transport.pipe.IPipe)

Example 2 with PluggableDefinition

use of buildcraft.api.transport.pluggable.PluggableDefinition in project BuildCraft by BuildCraft.

the class ItemPluggableGate method onPlace.

@Override
public PipePluggable onPlace(@Nonnull ItemStack stack, IPipeHolder holder, EnumFacing side, EntityPlayer player, EnumHand hand) {
    GateVariant variant = getVariant(stack);
    SoundUtil.playBlockPlace(holder.getPipeWorld(), holder.getPipePos(), variant.material.block.getDefaultState());
    PluggableDefinition def = BCTransportPlugs.gate;
    return new PluggableGate(def, holder, side, variant);
}
Also used : PluggableGate(buildcraft.transport.plug.PluggableGate) GateVariant(buildcraft.transport.gate.GateVariant) PluggableDefinition(buildcraft.api.transport.pluggable.PluggableDefinition)

Example 3 with PluggableDefinition

use of buildcraft.api.transport.pluggable.PluggableDefinition in project BuildCraft by BuildCraft.

the class PluggableHolder method readCreateInternal.

private void readCreateInternal(PacketBuffer buffer) throws InvalidInputDataException {
    ResourceLocation identifier = new ResourceLocation(buffer.readString(256));
    PluggableDefinition def = PipeApi.pluggableRegistry.getDefinition(identifier);
    if (def == null) {
        throw new IllegalStateException("Unknown remote pluggable \"" + identifier + "\"");
    }
    pluggable = def.loadFromBuffer(holder, side, buffer);
    holder.eventBus.registerHandler(pluggable);
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) PluggableDefinition(buildcraft.api.transport.pluggable.PluggableDefinition)

Example 4 with PluggableDefinition

use of buildcraft.api.transport.pluggable.PluggableDefinition in project BuildCraft by BuildCraft.

the class PluggableHolder method readFromNbt.

public void readFromNbt(NBTTagCompound nbt) {
    if (nbt.hasNoTags()) {
        pluggable = null;
        return;
    }
    String id = nbt.getString("id");
    NBTTagCompound data = nbt.getCompoundTag("data");
    ResourceLocation identifier = new ResourceLocation(id);
    PluggableDefinition def = PipeApi.pluggableRegistry.getDefinition(identifier);
    if (def == null) {
        BCLog.logger.warn("Unknown pluggable id '" + id + "'");
        throw new Error("Def was null!");
    } else {
        pluggable = def.readFromNbt(holder, side, data);
        holder.eventBus.registerHandler(pluggable);
        lastGeneralExisted = true;
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PluggableDefinition(buildcraft.api.transport.pluggable.PluggableDefinition)

Aggregations

PluggableDefinition (buildcraft.api.transport.pluggable.PluggableDefinition)4 ResourceLocation (net.minecraft.util.ResourceLocation)2 IFlowItems (buildcraft.api.transport.pipe.IFlowItems)1 IPipe (buildcraft.api.transport.pipe.IPipe)1 GateVariant (buildcraft.transport.gate.GateVariant)1 PluggableGate (buildcraft.transport.plug.PluggableGate)1 PluggableLens (buildcraft.transport.plug.PluggableLens)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1