Add all types of buffer and a lot of clean up to ALL GUIs.

Configurable IO rate still needed
This commit is contained in:
tterrag1098 committed 2014-12-18 01:19:10 -05:00
1 parent b4d5a88a75
commit 3add27b550
46 files changed
+559 -327

No files matched your search

@@ -0,0 +1,74 @@
package crazypants.enderio.machine.buffer;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlockWithMetadata;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import crazypants.enderio.ModObject;
public class BlockItemBuffer extends ItemBlockWithMetadata {
public enum Type {
BASIC(true, false, false),
POWER(false, true, false),
OMNI(true, true, false),
CREATIVE(true, true, true);
final boolean hasInventory;
final boolean hasPower;
final boolean isCreative;
private Type(boolean hasInventory, boolean hasPower, boolean isCreative) {
this.hasInventory = hasInventory;
this.hasPower = hasPower;
this.isCreative = isCreative;
}
public static Type get(TileBuffer buffer) {
return !buffer.hasPower() ? BASIC : !buffer.hasInventory() ? POWER : !buffer.isCreative() ? OMNI : CREATIVE;
}
public String getUnlocalizedName() {
return "tile." + ModObject.blockBuffer.unlocalisedName + "." + name().toLowerCase();
}
}
public BlockItemBuffer(Block block) {
super(block, block);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (Type type : Type.values()) {
list.add(new ItemStack(item, 1, type.ordinal()));
}
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return Type.values()[stack.getItemDamage()].getUnlocalizedName();
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);
if(world.getBlock(x, y, z) == field_150939_a) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileBuffer) {
TileBuffer buffer = ((TileBuffer) te);
Type t = Type.values()[metadata];
buffer.setHasInventory(t.hasInventory);
buffer.setHasPower(t.hasPower);
buffer.setCreative(t.isCreative);
}
}
return true;
}
}