Random Pipe API musings

This commit is contained in:
CovertJaguar 2013-12-01 22:15:03 -08:00
parent cc0298ce5b
commit c802c45c93
3 changed files with 81 additions and 25 deletions

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.pipes;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public interface IPipeDefinition {
String getUniqueTag();
void registerIcons(IconRegister iconRegister);
Icon getIcon(int index);
Icon getItemIcon();
PipeBehavior makePipeBehavior(TileEntity tile);
}

View file

@ -0,0 +1,51 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.pipes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public abstract class PipeBehavior {
public final TileEntity tile;
public PipeBehavior(TileEntity tile) {
this.tile = tile;
}
public void tick() {
}
public int getIconIndex(ForgeDirection side) {
return 0;
}
public void writeToNBT(NBTTagCompound nbt) {
}
public void readFromNBT(NBTTagCompound nbt) {
}
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
return true;
}
public boolean blockActivated(EntityPlayer player) {
return false;
}
public void onNeighborBlockChange(int blockId) {
}
}

View file

@ -1,25 +0,0 @@
package buildcraft.api.transport;
import java.lang.reflect.Method;
import net.minecraft.item.ItemStack;
/**
* You can use this if you wish, but FML InterModComms are recommended.
*
* SYNTAX: add-facade:id@meta
*/
public class FacadeManager {
private static Method addFacade;
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void addFacade(ItemStack is) {
try {
if (addFacade == null) {
Class facade = Class.forName("buildcraft.transport.ItemFacade");
addFacade = facade.getMethod("addFacade", ItemStack.class);
}
addFacade.invoke(null, is);
} catch (Exception ex) {
}
}
}