add new stamping crafting system with placeholder textures
This commit is contained in:
parent
8c77c24363
commit
9838582647
30 changed files with 1119 additions and 40 deletions
16
api/buildcraft/api/items/IItemCustomPipeRender.java
Normal file
16
api/buildcraft/api/items/IItemCustomPipeRender.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package buildcraft.api.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public interface IItemCustomPipeRender {
|
||||
float getPipeRenderScale(ItemStack stack);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return False to use the default renderer, true otherwise.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
boolean renderItemInPipe(ItemStack stack, double x, double y, double z);
|
||||
}
|
|
@ -321,6 +321,7 @@ item.Lens.name=Lens
|
|||
item.Filter.name=Filter
|
||||
item.debugger.name=Debugger
|
||||
item.debugger.warning=Use only for testing! Leaks secrets.
|
||||
item.package.name=Package
|
||||
|
||||
itemGroup.buildcraft.boards=BuildCraft Robots
|
||||
itemGroup.buildcraft.main=BuildCraft
|
||||
|
@ -352,6 +353,7 @@ tile.libraryBlock.name=Electronic Library
|
|||
tile.machineBlock.name=Quarry
|
||||
tile.markerBlock.name=Land Mark
|
||||
tile.miningWellBlock.name=Mining Well
|
||||
tile.packagerBlock.name=Recipe Packager
|
||||
tile.pathMarkerBlock.name=Path Mark
|
||||
tile.plainPipeBlock.name=Mining Pipe
|
||||
tile.programmingTableBlock.name=Programming Table
|
||||
|
@ -360,6 +362,7 @@ tile.refineryBlock.name=Refinery
|
|||
tile.requester.name=Requester
|
||||
tile.spring.oil.name=Oil Spring
|
||||
tile.spring.water.name=Water Spring
|
||||
tile.stampingTableBlock.name=Stamping Table
|
||||
tile.tankBlock.name=Tank
|
||||
tile.zonePlan.name=Zone Planner
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 407 B |
Binary file not shown.
After Width: | Height: | Size: 358 B |
Binary file not shown.
After Width: | Height: | Size: 458 B |
Binary file not shown.
After Width: | Height: | Size: 535 B |
Binary file not shown.
After Width: | Height: | Size: 808 B |
Binary file not shown.
After Width: | Height: | Size: 215 B |
|
@ -12,6 +12,7 @@ import java.io.File;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
@ -141,6 +142,7 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
Full, NoDynamic
|
||||
}
|
||||
|
||||
public static Random random = new Random();
|
||||
public static RenderMode render = RenderMode.Full;
|
||||
public static boolean debugWorldgen = false;
|
||||
public static boolean modifyWorld = false;
|
||||
|
|
|
@ -36,7 +36,9 @@ import buildcraft.core.lib.network.ChannelHandler;
|
|||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.silicon.BlockLaser;
|
||||
import buildcraft.silicon.BlockLaserTable;
|
||||
import buildcraft.silicon.BlockPackager;
|
||||
import buildcraft.silicon.ItemLaserTable;
|
||||
import buildcraft.silicon.ItemPackage;
|
||||
import buildcraft.silicon.ItemRedstoneChipset;
|
||||
import buildcraft.silicon.ItemRedstoneChipset.Chipset;
|
||||
import buildcraft.silicon.ResourceIdAssemblyTable;
|
||||
|
@ -47,7 +49,9 @@ import buildcraft.silicon.TileAssemblyTable;
|
|||
import buildcraft.silicon.TileChargingTable;
|
||||
import buildcraft.silicon.TileIntegrationTable;
|
||||
import buildcraft.silicon.TileLaser;
|
||||
import buildcraft.silicon.TilePackager;
|
||||
import buildcraft.silicon.TileProgrammingTable;
|
||||
import buildcraft.silicon.TileStampingTable;
|
||||
import buildcraft.silicon.network.PacketHandlerSilicon;
|
||||
|
||||
@Mod(name = "BuildCraft Silicon", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Silicon", dependencies = DefaultProps.DEPENDENCY_CORE)
|
||||
|
@ -56,8 +60,10 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
public static BuildCraftSilicon instance;
|
||||
|
||||
public static ItemRedstoneChipset redstoneChipset;
|
||||
public static ItemPackage packageItem;
|
||||
public static BlockLaser laserBlock;
|
||||
public static BlockLaserTable assemblyTableBlock;
|
||||
public static BlockPackager packagerBlock;
|
||||
public static Item redstoneCrystal;
|
||||
|
||||
public static Achievement timeForSomeLogicAchievement;
|
||||
|
@ -83,11 +89,19 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
assemblyTableBlock.setBlockName("laserTableBlock");
|
||||
CoreProxy.proxy.registerBlock(assemblyTableBlock, ItemLaserTable.class);
|
||||
|
||||
packagerBlock = (BlockPackager) CompatHooks.INSTANCE.getBlock(BlockPackager.class);
|
||||
packagerBlock.setBlockName("packagerBlock");
|
||||
CoreProxy.proxy.registerBlock(packagerBlock);
|
||||
|
||||
redstoneChipset = new ItemRedstoneChipset();
|
||||
redstoneChipset.setUnlocalizedName("redstoneChipset");
|
||||
CoreProxy.proxy.registerItem(redstoneChipset);
|
||||
redstoneChipset.registerItemStacks();
|
||||
|
||||
packageItem = new ItemPackage();
|
||||
packageItem.setUnlocalizedName("package");
|
||||
CoreProxy.proxy.registerItem(packageItem);
|
||||
|
||||
redstoneCrystal = (new ItemBuildCraft()).setUnlocalizedName("redstoneCrystal");
|
||||
CoreProxy.proxy.registerItem(redstoneCrystal);
|
||||
OreDictionary.registerOre("redstoneCrystal", new ItemStack(redstoneCrystal));
|
||||
|
@ -111,6 +125,8 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
"net.minecraft.src.buildcraft.factory.TileChargingTable");
|
||||
CoreProxy.proxy.registerTileEntity(TileProgrammingTable.class,
|
||||
"net.minecraft.src.buildcraft.factory.TileProgrammingTable");
|
||||
CoreProxy.proxy.registerTileEntity(TilePackager.class, "buildcraft.TilePackager");
|
||||
CoreProxy.proxy.registerTileEntity(TileStampingTable.class, "buildcraft.TileStampingTable");
|
||||
|
||||
BuilderAPI.schematicRegistry.registerSchematicBlock(laserBlock, SchematicRotateMeta.class, new int[] {2, 5, 3, 4}, true);
|
||||
|
||||
|
@ -137,51 +153,92 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
'R', "dustRedstone",
|
||||
'D', "gemDiamond");
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 0),
|
||||
"ORO",
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(laserBlock),
|
||||
"RRO",
|
||||
"RDD",
|
||||
"RRO",
|
||||
'O', Blocks.obsidian,
|
||||
'R', "dustRedstone",
|
||||
'D', "gemDiamond");
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(laserBlock),
|
||||
"RRR",
|
||||
"RDR",
|
||||
"ODO",
|
||||
'O', Blocks.obsidian,
|
||||
'R', "dustRedstone",
|
||||
'D', "gemDiamond");
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(laserBlock),
|
||||
"ODO",
|
||||
"RDR",
|
||||
"RRR",
|
||||
'O', Blocks.obsidian,
|
||||
'R', "dustRedstone",
|
||||
'D', "gemDiamond");
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 0),
|
||||
"ODO",
|
||||
"ORO",
|
||||
"OGO",
|
||||
'O', Blocks.obsidian,
|
||||
'R', "dustRedstone",
|
||||
'D', "gemDiamond",
|
||||
'G', "gearDiamond");
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 1),
|
||||
/* CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 1),
|
||||
"OWO",
|
||||
"OCO",
|
||||
"ORO",
|
||||
'O', Blocks.obsidian,
|
||||
'W', Blocks.crafting_table,
|
||||
'C', Blocks.chest,
|
||||
'R', new ItemStack(redstoneChipset, 1, 0));
|
||||
'R', new ItemStack(redstoneChipset, 1, 0)); */
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 2),
|
||||
"ORO",
|
||||
"OIO",
|
||||
"OCO",
|
||||
"OGO",
|
||||
'O', Blocks.obsidian,
|
||||
'R', "dustRedstone",
|
||||
'I', "ingotGold",
|
||||
'C', new ItemStack(redstoneChipset, 1, 0),
|
||||
'G', "gearDiamond");
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 3),
|
||||
"ORO",
|
||||
"OIO",
|
||||
"OCO",
|
||||
"OGO",
|
||||
'O', Blocks.obsidian,
|
||||
'R', "dustRedstone",
|
||||
'I', "dustRedstone",
|
||||
'C', new ItemStack(redstoneChipset, 1, 0),
|
||||
'G', "gearGold");
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 4),
|
||||
"ORO",
|
||||
"OCO",
|
||||
"ORO",
|
||||
"OGO",
|
||||
'O', Blocks.obsidian,
|
||||
'R', "dustRedstone",
|
||||
'R', new ItemStack(redstoneChipset, 1, 0),
|
||||
'C', Items.emerald,
|
||||
'G', "gearDiamond");
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 5),
|
||||
"OWO",
|
||||
"ORO",
|
||||
"OGO",
|
||||
'O', Blocks.obsidian,
|
||||
'W', Blocks.crafting_table,
|
||||
'G', "gearGold",
|
||||
'R', new ItemStack(redstoneChipset, 1, 0));
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(packagerBlock, 1, 0),
|
||||
" I ",
|
||||
"ICI",
|
||||
" P ",
|
||||
'I', "ingotIron",
|
||||
'C', Blocks.crafting_table,
|
||||
'P', Blocks.piston);
|
||||
|
||||
// CHIPSETS
|
||||
BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:redstoneChipset", Math.round(100000 * chipsetCostMultiplier), Chipset.RED.getStack(),
|
||||
"dustRedstone");
|
||||
|
|
11
common/buildcraft/core/lib/gui/ContainerDummy.java
Normal file
11
common/buildcraft/core/lib/gui/ContainerDummy.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package buildcraft.core.lib.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class ContainerDummy extends Container {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ import buildcraft.api.power.IRedstoneEngineReceiver;
|
|||
import buildcraft.api.tiles.IHasWork;
|
||||
import buildcraft.core.lib.RFBattery;
|
||||
import buildcraft.core.lib.block.TileBuildCraft;
|
||||
import buildcraft.core.lib.gui.ContainerDummy;
|
||||
import buildcraft.core.lib.inventory.InvUtils;
|
||||
import buildcraft.core.lib.inventory.InventoryConcatenator;
|
||||
import buildcraft.core.lib.inventory.InventoryIterator;
|
||||
|
@ -89,12 +90,7 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory
|
|||
public boolean useBindings, isJammed;
|
||||
|
||||
public LocalInventoryCrafting() {
|
||||
super(new Container() {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return false;
|
||||
}
|
||||
}, 3, 3);
|
||||
super(new ContainerDummy(), 3, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,6 @@ import net.minecraft.item.ItemStack;
|
|||
import buildcraft.core.lib.gui.BuildCraftContainer;
|
||||
import buildcraft.core.lib.gui.slots.SlotOutput;
|
||||
import buildcraft.core.lib.gui.slots.SlotUntouchable;
|
||||
import buildcraft.core.lib.gui.slots.SlotWorkbench;
|
||||
import buildcraft.factory.TileAutoWorkbench;
|
||||
|
||||
public class ContainerAutoWorkbench extends BuildCraftContainer {
|
||||
|
@ -48,12 +47,12 @@ public class ContainerAutoWorkbench extends BuildCraftContainer {
|
|||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new Slot(inventoryplayer, x + y * 9 + 9, 8 + x * 18, 116 + y * 18));
|
||||
addSlotToContainer(new Slot(inventoryplayer, x + y * 9 + 9, 8 + x * 18, 115 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new Slot(inventoryplayer, x, 8 + x * 18, 174));
|
||||
addSlotToContainer(new Slot(inventoryplayer, x, 8 + x * 18, 173));
|
||||
}
|
||||
|
||||
onCraftMatrixChanged(tile);
|
||||
|
|
|
@ -28,14 +28,6 @@ public class GuiAutoCrafting extends GuiBuildCraft {
|
|||
ySize = 197;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
if (this.mc.thePlayer != null) {
|
||||
inventorySlots.onContainerClosed(mc.thePlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
String title = StringUtils.localize("tile.autoWorkbenchBlock.name");
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
* 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.core.lib.gui.slots;
|
||||
package buildcraft.factory.gui;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.core.lib.gui.slots.SlotPhantom;
|
||||
|
||||
public class SlotWorkbench extends SlotPhantom {
|
||||
|
||||
public SlotWorkbench(IInventory iinventory, int slotIndex, int posX, int posY) {
|
||||
super(iinventory, slotIndex, posX, posY);
|
||||
}
|
|
@ -26,7 +26,7 @@ import buildcraft.core.BCCreativeTab;
|
|||
import buildcraft.core.lib.block.BlockBuildCraft;
|
||||
|
||||
public class BlockLaserTable extends BlockBuildCraft implements ILaserTargetBlock {
|
||||
protected static final int TABLE_MAX = 5;
|
||||
protected static final int TABLE_MAX = 6;
|
||||
|
||||
public BlockLaserTable() {
|
||||
super(Material.iron);
|
||||
|
@ -64,12 +64,6 @@ public class BlockLaserTable extends BlockBuildCraft implements ILaserTargetBloc
|
|||
return false;
|
||||
}
|
||||
|
||||
BlockInteractionEvent event = new BlockInteractionEvent(entityplayer, this, world.getBlockMetadata(i, j, k));
|
||||
FMLCommonHandler.instance().bus().post(event);
|
||||
if (event.isCanceled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
int meta = world.getBlockMetadata(i, j, k);
|
||||
entityplayer.openGui(BuildCraftSilicon.instance, meta, world, i, j, k);
|
||||
|
@ -90,6 +84,8 @@ public class BlockLaserTable extends BlockBuildCraft implements ILaserTargetBloc
|
|||
return new TileChargingTable();
|
||||
case 4:
|
||||
return new TileProgrammingTable();
|
||||
case 5:
|
||||
return new TileStampingTable();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -121,7 +117,8 @@ public class BlockLaserTable extends BlockBuildCraft implements ILaserTargetBloc
|
|||
"BuildCraft|Silicon:advancedCraftingTable",
|
||||
"BuildCraft|Silicon:integrationTable",
|
||||
"BuildCraft|Silicon:chargingTable",
|
||||
"BuildCraft|Silicon:programmingTable"
|
||||
"BuildCraft|Silicon:programmingTable",
|
||||
"BuildCraft|Silicon:stampingTable"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
35
common/buildcraft/silicon/BlockPackager.java
Normal file
35
common/buildcraft/silicon/BlockPackager.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package buildcraft.silicon;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.BuildCraftSilicon;
|
||||
import buildcraft.core.BCCreativeTab;
|
||||
import buildcraft.core.lib.block.BlockBuildCraft;
|
||||
|
||||
public class BlockPackager extends BlockBuildCraft {
|
||||
public BlockPackager() {
|
||||
super(Material.iron);
|
||||
|
||||
setHardness(10F);
|
||||
setCreativeTab(BCCreativeTab.get("main"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) {
|
||||
if (super.onBlockActivated(world, i, j, k, entityplayer, par6, par7, par8, par9)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftSilicon.instance, 10, world, i, j, k);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
return new TilePackager();
|
||||
}
|
||||
}
|
|
@ -33,6 +33,8 @@ public class ItemLaserTable extends ItemBlockBuildCraft {
|
|||
return "tile.chargingTableBlock";
|
||||
case 4:
|
||||
return "tile.programmingTableBlock";
|
||||
case 5:
|
||||
return "tile.stampingTableBlock";
|
||||
}
|
||||
return super.getUnlocalizedName();
|
||||
}
|
||||
|
|
53
common/buildcraft/silicon/ItemPackage.java
Normal file
53
common/buildcraft/silicon/ItemPackage.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
package buildcraft.silicon;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import buildcraft.core.lib.items.ItemBuildCraft;
|
||||
import buildcraft.core.lib.utils.NBTUtils;
|
||||
import buildcraft.silicon.render.PackageFontRenderer;
|
||||
|
||||
public class ItemPackage extends ItemBuildCraft {
|
||||
public ItemPackage() {
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
|
||||
}
|
||||
|
||||
public static IRecipe getRecipe(ItemStack stack) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void update(ItemStack stack) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public FontRenderer getFontRenderer(ItemStack stack) {
|
||||
return new PackageFontRenderer(stack);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List strings, boolean adv) {
|
||||
NBTTagCompound tag = NBTUtils.getItemData(stack);
|
||||
if (!tag.hasNoTags()) {
|
||||
strings.add("|S0 |S1 |S2");
|
||||
strings.add("|S3 |S4 |S5");
|
||||
strings.add("|S6 |S7 |S8");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,12 +16,16 @@ import buildcraft.silicon.gui.ContainerAdvancedCraftingTable;
|
|||
import buildcraft.silicon.gui.ContainerAssemblyTable;
|
||||
import buildcraft.silicon.gui.ContainerChargingTable;
|
||||
import buildcraft.silicon.gui.ContainerIntegrationTable;
|
||||
import buildcraft.silicon.gui.ContainerPackager;
|
||||
import buildcraft.silicon.gui.ContainerProgrammingTable;
|
||||
import buildcraft.silicon.gui.ContainerStampingTable;
|
||||
import buildcraft.silicon.gui.GuiAdvancedCraftingTable;
|
||||
import buildcraft.silicon.gui.GuiAssemblyTable;
|
||||
import buildcraft.silicon.gui.GuiChargingTable;
|
||||
import buildcraft.silicon.gui.GuiIntegrationTable;
|
||||
import buildcraft.silicon.gui.GuiPackager;
|
||||
import buildcraft.silicon.gui.GuiProgrammingTable;
|
||||
import buildcraft.silicon.gui.GuiStampingTable;
|
||||
|
||||
public class SiliconGuiHandler implements IGuiHandler {
|
||||
|
||||
|
@ -70,6 +74,20 @@ public class SiliconGuiHandler implements IGuiHandler {
|
|||
return new GuiProgrammingTable(player.inventory, (TileProgrammingTable) tile);
|
||||
}
|
||||
|
||||
case 5:
|
||||
if (!(tile instanceof TileStampingTable)) {
|
||||
return null;
|
||||
} else {
|
||||
return new GuiStampingTable(player.inventory, (TileStampingTable) tile);
|
||||
}
|
||||
|
||||
case 10:
|
||||
if (!(tile instanceof TilePackager)) {
|
||||
return null;
|
||||
} else {
|
||||
return new GuiPackager(player.inventory, (TilePackager) tile);
|
||||
}
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -120,6 +138,20 @@ public class SiliconGuiHandler implements IGuiHandler {
|
|||
return new ContainerProgrammingTable(player.inventory, (TileProgrammingTable) tile);
|
||||
}
|
||||
|
||||
case 5:
|
||||
if (!(tile instanceof TileStampingTable)) {
|
||||
return null;
|
||||
} else {
|
||||
return new ContainerStampingTable(player.inventory, (TileStampingTable) tile);
|
||||
}
|
||||
|
||||
case 10:
|
||||
if (!(tile instanceof TilePackager)) {
|
||||
return null;
|
||||
} else {
|
||||
return new ContainerPackager(player.inventory, (TilePackager) tile);
|
||||
}
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
266
common/buildcraft/silicon/TilePackager.java
Normal file
266
common/buildcraft/silicon/TilePackager.java
Normal file
|
@ -0,0 +1,266 @@
|
|||
package buildcraft.silicon;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftSilicon;
|
||||
import buildcraft.core.lib.block.TileBuildCraft;
|
||||
import buildcraft.core.lib.inventory.InventoryConcatenator;
|
||||
import buildcraft.core.lib.inventory.SimpleInventory;
|
||||
import buildcraft.core.lib.inventory.StackHelper;
|
||||
import buildcraft.core.lib.utils.NBTUtils;
|
||||
import buildcraft.core.lib.utils.Utils;
|
||||
|
||||
public class TilePackager extends TileBuildCraft implements ISidedInventory {
|
||||
private static final int[] SLOTS = Utils.createSlotArray(0, 12);
|
||||
|
||||
public SimpleInventory inventoryPublic = new SimpleInventory(12, "Packager", 64);
|
||||
public SimpleInventory inventoryPattern = new SimpleInventory(9, "Packager", 64);
|
||||
public IInventory visibleInventory = InventoryConcatenator.make().add(inventoryPublic).add(inventoryPattern);
|
||||
|
||||
private int patternsSet;
|
||||
private int updateTime = BuildCraftCore.random.nextInt(5);
|
||||
|
||||
public boolean isPatternSlotSet(int p) {
|
||||
return (patternsSet & (1 << p)) != 0;
|
||||
}
|
||||
|
||||
public void setPatternSlot(int p, boolean v) {
|
||||
if (v) {
|
||||
patternsSet |= 1 << p;
|
||||
} else {
|
||||
patternsSet &= ~(1 << p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((updateTime++) % 5 == 0) {
|
||||
attemptCrafting(inventoryPublic.getStackInSlot(9));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean attemptCrafting(ItemStack input) {
|
||||
// STEP 0: Make sure the conditions are correct.
|
||||
if (inventoryPublic.getStackInSlot(11) != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (input == null || input.stackSize == 0 || !(input.getItem() == Items.paper || input.getItem() instanceof ItemPackage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (input.getItem() instanceof ItemPackage) {
|
||||
NBTTagCompound inputTag = NBTUtils.getItemData(input);
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (isPatternSlotSet(i) && inputTag.hasKey("item" + i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 1: Find how many "missing patterns" we have,
|
||||
// and find the first item matching this.
|
||||
// Also, match all the non-missing patterns.
|
||||
int missingCount = 0;
|
||||
int[] bindings = new int[9];
|
||||
int[] usedItems = new int[9];
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (isPatternSlotSet(i)) {
|
||||
ItemStack inputStack = inventoryPattern.getStackInSlot(i);
|
||||
if (inputStack == null) {
|
||||
missingCount++;
|
||||
} else {
|
||||
boolean found = false;
|
||||
for (int j = 0; j < 9; j++) {
|
||||
ItemStack comparedStack = inventoryPublic.getStackInSlot(j);
|
||||
if (comparedStack != null && usedItems[j] < comparedStack.stackSize
|
||||
&& StackHelper.isMatchingItem(inputStack, comparedStack, true, false)) {
|
||||
usedItems[j]++;
|
||||
bindings[i] = j;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 2: If we have any missings, find the first stack
|
||||
// which is NOT used elsewhere AND has enough items.
|
||||
if (missingCount > 0) {
|
||||
int missingPos = -1;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (usedItems[i] == 0) {
|
||||
ItemStack comparedStack = inventoryPublic.getStackInSlot(i);
|
||||
if (comparedStack != null && comparedStack.stackSize >= missingCount) {
|
||||
missingPos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (missingPos < 0) {
|
||||
return false;
|
||||
} else {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (isPatternSlotSet(i)) {
|
||||
ItemStack inputStack = inventoryPattern.getStackInSlot(i);
|
||||
if (inputStack == null) {
|
||||
bindings[i] = missingPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 3: Craft and output.
|
||||
ItemStack pkg;
|
||||
if (input.getItem() instanceof ItemPackage) {
|
||||
pkg = input.copy();
|
||||
} else {
|
||||
pkg = new ItemStack(BuildCraftSilicon.packageItem);
|
||||
}
|
||||
NBTTagCompound pkgTag = NBTUtils.getItemData(pkg);
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (isPatternSlotSet(i)) {
|
||||
ItemStack usedStack = inventoryPublic.getStackInSlot(bindings[i]);
|
||||
ItemStack output = usedStack.splitStack(1);
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
output.writeToNBT(itemTag);
|
||||
pkgTag.setTag("item" + i, itemTag);
|
||||
}
|
||||
}
|
||||
|
||||
ItemPackage.update(pkg);
|
||||
|
||||
decrStackSize(9, 1);
|
||||
setInventorySlotContents(11, pkg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(ByteBuf stream) {
|
||||
super.readData(stream);
|
||||
patternsSet = stream.readUnsignedShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(ByteBuf stream) {
|
||||
super.writeData(stream);
|
||||
stream.writeShort(patternsSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound cpd) {
|
||||
super.readFromNBT(cpd);
|
||||
inventoryPublic.readFromNBT(cpd, "items");
|
||||
inventoryPattern.readFromNBT(cpd, "pattern");
|
||||
patternsSet = cpd.getShort("patternSet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound cpd) {
|
||||
super.writeToNBT(cpd);
|
||||
inventoryPublic.writeToNBT(cpd, "items");
|
||||
inventoryPattern.writeToNBT(cpd, "pattern");
|
||||
cpd.setShort("patternSet", (short) patternsSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return visibleInventory.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return visibleInventory.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
return visibleInventory.decrStackSize(slot, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return visibleInventory.getStackInSlotOnClosing(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
visibleInventory.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "Packager";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return visibleInventory.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
visibleInventory.openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
visibleInventory.closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
if (slot == 9) {
|
||||
return (stack == null || stack.getItem() == Items.paper || stack.getItem() instanceof ItemPackage);
|
||||
}
|
||||
return visibleInventory.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return SLOTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side) {
|
||||
if (side >= 2) {
|
||||
return slot < 9;
|
||||
} else {
|
||||
return slot == 9;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side) {
|
||||
return slot == 11;
|
||||
}
|
||||
}
|
187
common/buildcraft/silicon/TileStampingTable.java
Normal file
187
common/buildcraft/silicon/TileStampingTable.java
Normal file
|
@ -0,0 +1,187 @@
|
|||
package buildcraft.silicon;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.core.IInvSlot;
|
||||
import buildcraft.api.tiles.IHasWork;
|
||||
import buildcraft.core.lib.gui.ContainerDummy;
|
||||
import buildcraft.core.lib.inventory.InventoryIterator;
|
||||
import buildcraft.core.lib.inventory.StackHelper;
|
||||
import buildcraft.core.lib.utils.CraftingUtils;
|
||||
import buildcraft.core.lib.utils.NBTUtils;
|
||||
import buildcraft.core.lib.utils.StringUtils;
|
||||
import buildcraft.core.lib.utils.Utils;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
|
||||
public class TileStampingTable extends TileLaserTableBase implements IHasWork, ISidedInventory {
|
||||
private class LocalInventoryCrafting extends InventoryCrafting {
|
||||
public LocalInventoryCrafting() {
|
||||
super(new ContainerDummy(), 3, 3);
|
||||
}
|
||||
|
||||
private IRecipe findRecipe() {
|
||||
for (IInvSlot slot : InventoryIterator.getIterable(this, ForgeDirection.UP)) {
|
||||
ItemStack stack = slot.getStackInSlot();
|
||||
if (stack == null) {
|
||||
continue;
|
||||
}
|
||||
if (stack.getItem().hasContainerItem(stack)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return CraftingUtils.findMatchingRecipe(this, worldObj);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int[] SLOTS = Utils.createSlotArray(0, 2);
|
||||
private SlotCrafting craftSlot;
|
||||
private final LocalInventoryCrafting crafting = new LocalInventoryCrafting();
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return !FMLCommonHandler.instance().getEffectiveSide().isClient();
|
||||
}
|
||||
|
||||
public WeakReference<EntityPlayer> getInternalPlayer() {
|
||||
return CoreProxy.proxy.getBuildCraftPlayer((WorldServer) worldObj, xCoord, yCoord + 1, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (getEnergy() >= getRequiredEnergy()) {
|
||||
ItemStack input = this.getStackInSlot(0);
|
||||
|
||||
if (input == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (craftSlot == null) {
|
||||
craftSlot = new SlotCrafting(getInternalPlayer().get(), crafting, this, 1, 0, 0);
|
||||
}
|
||||
|
||||
if (input.getItem() instanceof ItemPackage) {
|
||||
// Try a recipe made out of the package's contents
|
||||
NBTTagCompound tag = NBTUtils.getItemData(input);
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (tag.hasKey("item" + i)) {
|
||||
crafting.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(tag.getCompoundTag("item" + i)));
|
||||
} else {
|
||||
crafting.setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Try a shapeless recipe made from just that item
|
||||
ItemStack input2 = input.copy();
|
||||
input2.stackSize = 1;
|
||||
crafting.setInventorySlotContents(0, input2);
|
||||
for (int i = 1; i < 9; i++) {
|
||||
crafting.setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
|
||||
IRecipe recipe = crafting.findRecipe();
|
||||
ItemStack result = recipe != null ? recipe.getCraftingResult(crafting).copy() : null;
|
||||
ItemStack resultInto = this.getStackInSlot(1);
|
||||
|
||||
if (recipe == null || result == null || result.stackSize <= 0) {
|
||||
if (resultInto == null || StackHelper.canStacksMerge(input, resultInto)) {
|
||||
this.setInventorySlotContents(0, null);
|
||||
this.setInventorySlotContents(1, input);
|
||||
}
|
||||
return;
|
||||
} else if (resultInto != null &&
|
||||
(!StackHelper.canStacksMerge(result, resultInto) ||
|
||||
resultInto.stackSize + result.stackSize > result.getMaxStackSize())) {
|
||||
return;
|
||||
}
|
||||
|
||||
addEnergy(-getRequiredEnergy());
|
||||
|
||||
craftSlot.onPickupFromSlot(getInternalPlayer().get(), result);
|
||||
|
||||
if (resultInto == null) {
|
||||
setInventorySlotContents(1, result);
|
||||
} else {
|
||||
resultInto.stackSize += result.stackSize;
|
||||
}
|
||||
|
||||
decrStackSize(0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredEnergy() {
|
||||
ItemStack stack = this.getStackInSlot(0);
|
||||
ItemStack output = this.getStackInSlot(1);
|
||||
if (output != null && output.stackSize == output.getMaxStackSize()) {
|
||||
return 0;
|
||||
}
|
||||
if (stack != null && stack.getItem() != null) {
|
||||
if (stack.getItem() instanceof ItemPackage) {
|
||||
// tagMap size
|
||||
return 400 * NBTUtils.getItemData(stack).func_150296_c().size();
|
||||
} else {
|
||||
return 400;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWork() {
|
||||
return getRequiredEnergy() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraft() {
|
||||
return hasWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return StringUtils.localize("tile.stampingTableBlock.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
return slot == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int p_94128_1_) {
|
||||
return SLOTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side) {
|
||||
return slot == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side) {
|
||||
return slot == 1;
|
||||
}
|
||||
}
|
119
common/buildcraft/silicon/gui/ContainerPackager.java
Normal file
119
common/buildcraft/silicon/gui/ContainerPackager.java
Normal file
|
@ -0,0 +1,119 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
|
||||
* 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.silicon.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.core.lib.gui.BuildCraftContainer;
|
||||
import buildcraft.core.lib.gui.slots.IPhantomSlot;
|
||||
import buildcraft.core.lib.gui.slots.SlotOutput;
|
||||
import buildcraft.core.lib.gui.slots.SlotValidated;
|
||||
import buildcraft.silicon.TilePackager;
|
||||
|
||||
public class ContainerPackager extends BuildCraftContainer {
|
||||
private final TilePackager tile;
|
||||
// private int lastProgress;
|
||||
|
||||
public ContainerPackager(InventoryPlayer inventoryplayer, TilePackager t) {
|
||||
super(t.getSizeInventory());
|
||||
|
||||
this.tile = t;
|
||||
|
||||
// sort in order of shift-click!
|
||||
|
||||
addSlotToContainer(new SlotValidated(tile, 9, 124, 7));
|
||||
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new Slot(tile, x, 8 + x * 18, 84));
|
||||
}
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
addSlotToContainer(new SlotPackager(tile, 12 + x + y * 3, 30 + x * 18, 17 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(new Slot(tile, 10, 108, 31));
|
||||
addSlotToContainer(new SlotOutput(tile, 11, 123, 59));
|
||||
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new Slot(inventoryplayer, x + y * 9 + 9, 8 + x * 18, 115 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new Slot(inventoryplayer, x, 8 + x * 18, 173));
|
||||
}
|
||||
|
||||
onCraftMatrixChanged(tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting icrafting) {
|
||||
super.addCraftingToCrafters(icrafting);
|
||||
//icrafting.sendProgressBarUpdate(this, 0, tile.progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
/*for (int i = 0; i < crafters.size(); i++) {
|
||||
ICrafting icrafting = (ICrafting) crafters.get(i);
|
||||
|
||||
if (lastProgress != tile.progress) {
|
||||
icrafting.sendProgressBarUpdate(this, 0, tile.progress);
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack output = craftResult.getStackInSlot(0);
|
||||
if (output != prevOutput) {
|
||||
prevOutput = output;
|
||||
onCraftMatrixChanged(tile.craftMatrix);
|
||||
}
|
||||
|
||||
lastProgress = tile.progress;*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int id, int data) {
|
||||
/*switch (id) {
|
||||
case 0:
|
||||
tile.progress = data;
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) {
|
||||
ItemStack out = super.slotClick(slotNum, mouseButton, modifier, player);
|
||||
Slot slot = slotNum < 0 ? null : (Slot) this.inventorySlots.get(slotNum);
|
||||
|
||||
if (slot instanceof SlotPackager) {
|
||||
int idx = slot.getSlotIndex() - 12;
|
||||
ItemStack stack = player != null && player.inventory != null ? player.inventory.getItemStack() : null;
|
||||
if (stack == null) {
|
||||
tile.setPatternSlot(idx, !tile.isPatternSlotSet(idx));
|
||||
} else {
|
||||
tile.setPatternSlot(idx, true);
|
||||
}
|
||||
tile.sendNetworkUpdate();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return tile.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
}
|
60
common/buildcraft/silicon/gui/ContainerStampingTable.java
Normal file
60
common/buildcraft/silicon/gui/ContainerStampingTable.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
|
||||
* 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.silicon.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import buildcraft.core.lib.gui.BuildCraftContainer;
|
||||
import buildcraft.core.lib.gui.slots.SlotOutput;
|
||||
import buildcraft.core.lib.gui.slots.SlotUntouchable;
|
||||
import buildcraft.core.lib.gui.slots.SlotValidated;
|
||||
import buildcraft.silicon.TileStampingTable;
|
||||
|
||||
public class ContainerStampingTable extends BuildCraftContainer {
|
||||
|
||||
private TileStampingTable table;
|
||||
|
||||
public ContainerStampingTable(InventoryPlayer playerInventory, TileStampingTable table) {
|
||||
super(table.getSizeInventory());
|
||||
this.table = table;
|
||||
|
||||
addSlot(new SlotValidated(table, 0, 15, 18));
|
||||
addSlot(new SlotOutput(table, 1, 143, 18));
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new Slot(playerInventory, x + y * 9 + 9, 8 + x * 18, 50 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new Slot(playerInventory, x, 8 + x * 18, 108));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer var1) {
|
||||
return table.isUseableByPlayer(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < crafters.size(); i++) {
|
||||
table.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int par1, int par2) {
|
||||
table.getGUINetworkData(par1, par2);
|
||||
}
|
||||
}
|
53
common/buildcraft/silicon/gui/GuiPackager.java
Normal file
53
common/buildcraft/silicon/gui/GuiPackager.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
|
||||
* 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.silicon.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.core.lib.gui.GuiBuildCraft;
|
||||
import buildcraft.core.lib.utils.StringUtils;
|
||||
import buildcraft.silicon.TilePackager;
|
||||
|
||||
public class GuiPackager extends GuiBuildCraft {
|
||||
|
||||
public static final ResourceLocation TEXTURE = new ResourceLocation("buildcraftsilicon:textures/gui/packager.png");
|
||||
private TilePackager bench;
|
||||
|
||||
public GuiPackager(InventoryPlayer inventoryplayer, TilePackager tile) {
|
||||
super(new ContainerPackager(inventoryplayer, tile), tile, TEXTURE);
|
||||
this.bench = tile;
|
||||
xSize = 176;
|
||||
ySize = 197;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(TEXTURE);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
if (bench.isPatternSlotSet(y * 3 + x)) {
|
||||
drawTexturedModalRect(guiLeft + 29 + x * 18, guiTop + 16 + y * 18, xSize, 0, 18, 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*if (bench.progress > 0) {
|
||||
int progress = bench.getProgressScaled(23);
|
||||
drawTexturedModalRect(guiLeft + 89, guiTop + 45, 176, 0, progress + 1, 12);
|
||||
}*/
|
||||
}
|
||||
}
|
61
common/buildcraft/silicon/gui/GuiStampingTable.java
Normal file
61
common/buildcraft/silicon/gui/GuiStampingTable.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
|
||||
* 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.silicon.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import buildcraft.silicon.TileStampingTable;
|
||||
|
||||
public class GuiStampingTable extends GuiLaserTable {
|
||||
|
||||
public static final ResourceLocation TEXTURE = new ResourceLocation("buildcraftsilicon:textures/gui/stamper.png");
|
||||
private static final int FLASH_DELAY = 3;
|
||||
private final TileStampingTable integrationTable;
|
||||
private boolean flash;
|
||||
private int flashDelay;
|
||||
|
||||
public GuiStampingTable(InventoryPlayer playerInventory, TileStampingTable table) {
|
||||
super(playerInventory, new ContainerStampingTable(playerInventory, table), table, TEXTURE);
|
||||
this.integrationTable = table;
|
||||
xSize = 176;
|
||||
ySize = 132;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
|
||||
if (flashDelay <= 0) {
|
||||
flashDelay = FLASH_DELAY;
|
||||
flash = !flash;
|
||||
} else {
|
||||
flashDelay--;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
drawLedgers(par1, par2);
|
||||
|
||||
String title = table.getInventoryName();
|
||||
fontRendererObj.drawString(title, getCenteredOffset(title), 5, 0x404040);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(TEXTURE);
|
||||
if (integrationTable.getEnergy() > 0) {
|
||||
int progress = integrationTable.getProgressScaled(98);
|
||||
drawTexturedModalRect(guiLeft + 36, guiTop + 14, 0, flash ? 197 : 221, progress, 24);
|
||||
}
|
||||
}
|
||||
}
|
30
common/buildcraft/silicon/gui/SlotPackager.java
Normal file
30
common/buildcraft/silicon/gui/SlotPackager.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
|
||||
* 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.silicon.gui;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import buildcraft.core.lib.gui.slots.SlotPhantom;
|
||||
import buildcraft.silicon.TilePackager;
|
||||
|
||||
public class SlotPackager extends SlotPhantom {
|
||||
public SlotPackager(IInventory iinventory, int slotIndex, int posX, int posY) {
|
||||
super(iinventory, slotIndex, posX, posY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack != null && !stack.getItem().hasContainerItem(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShift() {
|
||||
return false;
|
||||
}
|
||||
}
|
91
common/buildcraft/silicon/render/PackageFontRenderer.java
Normal file
91
common/buildcraft/silicon/render/PackageFontRenderer.java
Normal file
|
@ -0,0 +1,91 @@
|
|||
package buildcraft.silicon.render;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import buildcraft.core.lib.utils.NBTUtils;
|
||||
|
||||
public class PackageFontRenderer extends FontRenderer {
|
||||
private static final RenderItem itemRender = new RenderItem();
|
||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||
private static final FontRenderer realRenderer = mc.fontRenderer;
|
||||
private final ItemStack packageStack;
|
||||
private final NBTTagCompound pkgTag;
|
||||
|
||||
public PackageFontRenderer(ItemStack packageStack) {
|
||||
super(mc.gameSettings, new ResourceLocation("textures/font/ascii.png"), mc.getTextureManager(), mc.fontRenderer.getUnicodeFlag());
|
||||
this.packageStack = packageStack;
|
||||
this.pkgTag = NBTUtils.getItemData(packageStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStringWidth(String s) {
|
||||
if (s.indexOf("|") < 0) {
|
||||
return realRenderer.getStringWidth(s);
|
||||
}
|
||||
|
||||
String output = s;
|
||||
int w = 0;
|
||||
|
||||
while (output.indexOf("|") >= 0) {
|
||||
String pre = output.substring(0, output.indexOf("|"));
|
||||
w += realRenderer.getStringWidth(pre);
|
||||
|
||||
String text = output.substring(output.indexOf("|") + 1).split(" ")[0];
|
||||
if (text.startsWith("S")) {
|
||||
w += 5;
|
||||
}
|
||||
|
||||
output = output.substring(output.indexOf("|") + text.length() + 1);
|
||||
}
|
||||
w += realRenderer.getStringWidth(output);
|
||||
return w;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drawString(String s, int x, int y, int color, boolean shadow) {
|
||||
if (s.indexOf("|") < 0) {
|
||||
return realRenderer.drawString(s, x, y, color, shadow);
|
||||
}
|
||||
|
||||
String output = s;
|
||||
int rx = x;
|
||||
|
||||
while (output.indexOf("|") >= 0) {
|
||||
String pre = output.substring(0, output.indexOf("|"));
|
||||
rx = realRenderer.drawString(pre, rx, y, color, shadow);
|
||||
GL11.glPushMatrix();
|
||||
|
||||
String text = output.substring(output.indexOf("|") + 1).split(" ")[0];
|
||||
if (text.startsWith("S")) {
|
||||
int slotPos = Integer.parseInt(text.substring(1));
|
||||
if (pkgTag.hasKey("item" + slotPos)) {
|
||||
ItemStack slotStack = ItemStack.loadItemStackFromNBT(pkgTag.getCompoundTag("item" + slotPos));
|
||||
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
FontRenderer font = slotStack.getItem().getFontRenderer(slotStack);
|
||||
itemRender.zLevel = 200.0F;
|
||||
|
||||
if (font == null || font instanceof PackageFontRenderer) {
|
||||
font = Minecraft.getMinecraft().fontRenderer;
|
||||
}
|
||||
|
||||
itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), slotStack, rx * 2, y * 2);
|
||||
itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), slotStack, rx * 2, y * 2);
|
||||
itemRender.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
rx += 5;
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
output = output.substring(output.indexOf("|") + text.length() + 1);
|
||||
}
|
||||
rx = realRenderer.drawString(output, rx, y, color, shadow);
|
||||
return rx;
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ public class RenderLaserTable implements ISimpleBlockRenderingHandler {
|
|||
renderAssemblyTable(renderer, true, 0, 0, 0, bcBlock);
|
||||
break;
|
||||
case 1:
|
||||
case 5:
|
||||
renderAdvancedCraftingTable(renderer, true, 0, 0, 0, bcBlock);
|
||||
break;
|
||||
case 2:
|
||||
|
@ -53,6 +54,7 @@ public class RenderLaserTable implements ISimpleBlockRenderingHandler {
|
|||
renderAssemblyTable(renderer, false, x, y, z, bcBlock);
|
||||
break;
|
||||
case 1:
|
||||
case 5:
|
||||
renderAdvancedCraftingTable(renderer, false, x, y, z, bcBlock);
|
||||
break;
|
||||
case 2:
|
||||
|
|
|
@ -33,6 +33,7 @@ import buildcraft.BuildCraftTransport;
|
|||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.gates.IGateExpansion;
|
||||
import buildcraft.api.items.IItemCustomPipeRender;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
import buildcraft.core.CoreConstants;
|
||||
|
@ -802,9 +803,23 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
|
|||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||
GL11.glTranslatef(0, 0.25F, 0);
|
||||
GL11.glScalef(renderScale, renderScale, renderScale);
|
||||
dummyEntityItem.setEntityItemStack(itemstack);
|
||||
customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);
|
||||
if (itemstack.getItem() instanceof IItemCustomPipeRender) {
|
||||
IItemCustomPipeRender render = (IItemCustomPipeRender) itemstack.getItem();
|
||||
float itemScale = render.getPipeRenderScale(itemstack);
|
||||
GL11.glScalef(renderScale * itemScale, renderScale * itemScale, renderScale * itemScale);
|
||||
itemScale = 1 / itemScale;
|
||||
|
||||
if (!render.renderItemInPipe(itemstack, x, y, z)) {
|
||||
dummyEntityItem.setEntityItemStack(itemstack);
|
||||
customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
GL11.glScalef(itemScale, itemScale, itemScale);
|
||||
} else {
|
||||
GL11.glScalef(renderScale, renderScale, renderScale);
|
||||
dummyEntityItem.setEntityItemStack(itemstack);
|
||||
customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
if (color != null) {
|
||||
bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
|
Loading…
Reference in a new issue