diff options
21 files changed, 978 insertions, 14 deletions
diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index 35dd65a8f1..5bff9dd744 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -21,6 +21,7 @@ import net.minecraftforge.fluids.Fluid; public final class ModBlocks { + public static Block blockCircuitProgrammer; public static Block blockFakeMiningPipe; public static Block blockFakeMiningHead; @@ -95,7 +96,7 @@ public final class ModBlocks { blockFirePit = new FirePit(); blockFishTrap = new FishTrap(); blockInfiniteFLuidTank = new FluidTankInfinite(); - blockOreFluorite = new BlockBaseOre.oldOreBlock("oreFluorite", "Fluorite", Material.rock, BlockTypes.ORE, Utils.rgbtoHexValue(120, 120, 30), 3); + //blockOreFluorite = new BlockBaseOre.oldOreBlock("oreFluorite", "Fluorite", Material.rock, BlockTypes.ORE, Utils.rgbtoHexValue(120, 120, 30), 3); blockMiningExplosive = new MiningExplosives(); blockHellfire = new HellFire(); blockProjectTable = new Machine_ProjectTable(); @@ -109,6 +110,8 @@ public final class ModBlocks { blockFakeMiningPipe = new Mining_Pipe_Fake(); blockFakeMiningHead = new Mining_Head_Fake(); + blockCircuitProgrammer = new CircuitProgrammer(); + blockPlayerDoorWooden = new PlayerDoors(Material.wood, "door_wood", true); blockPlayerDoorIron = new PlayerDoors(Material.iron, "door_iron", true); blockPlayerDoorCustom_Glass = new PlayerDoors(Material.glass, "door_glass", false); diff --git a/src/Java/gtPlusPlus/core/block/general/MiningExplosives.java b/src/Java/gtPlusPlus/core/block/general/MiningExplosives.java index ceb35ad673..45345ef176 100644 --- a/src/Java/gtPlusPlus/core/block/general/MiningExplosives.java +++ b/src/Java/gtPlusPlus/core/block/general/MiningExplosives.java @@ -30,11 +30,10 @@ public class MiningExplosives extends BlockTNT { private IIcon textureBottom; public MiningExplosives(){ - this.setCreativeTab(AddToCreativeTab.tabMachines); this.setBlockName("blockMiningExplosives"); - this.setCreativeTab(AddToCreativeTab.tabMachines); GameRegistry.registerBlock(this, "blockMiningExplosives"); LanguageRegistry.addName(this, "Earth Blasting Explosives"); + this.setCreativeTab(AddToCreativeTab.tabMachines); } /** diff --git a/src/Java/gtPlusPlus/core/block/machine/CircuitProgrammer.java b/src/Java/gtPlusPlus/core/block/machine/CircuitProgrammer.java new file mode 100644 index 0000000000..e89ccf367f --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/CircuitProgrammer.java @@ -0,0 +1,135 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; +import gtPlusPlus.core.util.minecraft.InventoryUtils; + +public class CircuitProgrammer extends BlockContainer implements ITileTooltip +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 4; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public CircuitProgrammer(){ + super(Material.iron); + this.setBlockName("blockCircuitProgrammer"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockCircuitProgrammer"); + LanguageRegistry.addName(this, "Circuit Programmer"); + + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) + { + return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_B"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_G"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_I"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityCircuitProgrammer)){ + player.openGui(GTplusplus.instance, GuiHandler.GUI8, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityCircuitProgrammer(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityCircuitProgrammer) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/container/Container_CircuitProgrammer.java b/src/Java/gtPlusPlus/core/container/Container_CircuitProgrammer.java new file mode 100644 index 0000000000..c71fb44b65 --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_CircuitProgrammer.java @@ -0,0 +1,145 @@ +package gtPlusPlus.core.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.InventoryCircuitProgrammer; +import gtPlusPlus.core.slots.SlotIntegratedCircuit; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; + +public class Container_CircuitProgrammer extends Container { + + protected TileEntityCircuitProgrammer tile_entity; + public final InventoryCircuitProgrammer inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static int StorageSlotNumber = 26; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots + + private final int[] slotStorage = new int[26]; + + public Container_CircuitProgrammer(final InventoryPlayer inventory, final TileEntityCircuitProgrammer te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + + int o = 0; + + // Storage Side + /*for (var6 = 0; var6 < 3; var6++) { + for (var7 = 0; var7 < 5; var7++) { + this.slotStorage[o] = o; + this.addSlotToContainer(new SlotIntegratedCircuit(o, this.inventoryChest, o, 44 + (var7 * 18), 15 + (var6 * 18))); + o++; + } + }*/ + + //Add Output + //this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, 44 + (6 * 18), 15 + (3 * 18))); + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, o++, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, o++, 8 + (var6 * 18), 142)); + } + + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, + final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockFishTrap) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + // Can merge Slot + @Override + public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { + return super.func_94530_a(p_94530_1_, p_94530_2_); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_CircuitProgrammer.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_CircuitProgrammer.java new file mode 100644 index 0000000000..398774c48f --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_CircuitProgrammer.java @@ -0,0 +1,47 @@ +package gtPlusPlus.core.gui.machine; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import gtPlusPlus.core.container.Container_CircuitProgrammer; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; + +@SideOnly(Side.CLIENT) +public class GUI_CircuitProgrammer extends GuiContainer { + + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/CircuitProgrammer.png"); + + public GUI_CircuitProgrammer(final InventoryPlayer player_inventory, final TileEntityCircuitProgrammer te){ + super(new Container_CircuitProgrammer(player_inventory, te)); + } + + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j){ + + } + + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + + //This method is called when the Gui is first called! + @Override + public void initGui(){ + super.initGui(); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index 44ff165a1b..36acb6d65a 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -15,12 +15,12 @@ import gtPlusPlus.core.gui.beta.Gui_ID_Registry; import gtPlusPlus.core.gui.beta.MU_GuiId; import gtPlusPlus.core.gui.item.GuiBaseBackpack; import gtPlusPlus.core.gui.item.GuiBaseGrindle; -import gtPlusPlus.core.gui.item.GuiScreenGrindle; import gtPlusPlus.core.gui.machine.*; import gtPlusPlus.core.interfaces.IGuiManager; import gtPlusPlus.core.inventories.BaseInventoryBackpack; import gtPlusPlus.core.inventories.BaseInventoryGrindle; import gtPlusPlus.core.tileentities.base.TileEntityBase; +import gtPlusPlus.core.tileentities.general.TileEntityCircuitProgrammer; import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; import gtPlusPlus.core.tileentities.machines.*; @@ -33,7 +33,7 @@ public class GuiHandler implements IGuiHandler { public static final int GUI5 = 4; //Workbench Adv public static final int GUI6 = 5; //Fish trap public static final int GUI7 = 6; //Trade table - public static final int GUI8 = 7; //Alchemical Furnace + public static final int GUI8 = 7; //Circuit Programmer public static final int GUI9 = 8; //Grindle @@ -82,7 +82,7 @@ public class GuiHandler implements IGuiHandler { return new Container_TradeTable(player.inventory, (TileEntityTradeTable)te); } else if (ID == GUI8){ - //return new ContainerFastAlchemyFurnace(player.inventory, (TileFastAlchemyFurnace)te); + return new Container_CircuitProgrammer(player.inventory, (TileEntityCircuitProgrammer)te); } } @@ -134,7 +134,7 @@ public class GuiHandler implements IGuiHandler { return new GUI_TradeTable(player.inventory, (TileEntityTradeTable)te, ((TileEntityBase) te).getOwner()); } else if (ID == GUI8){ - //return new GuiFastAlchemyFurnace(player.inventory, (TileFastAlchemyFurnace)te); + return new GUI_CircuitProgrammer(player.inventory, (TileEntityCircuitProgrammer)te); } } diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java b/src/Java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java new file mode 100644 index 0000000000..4cdbb72c6e --- /dev/null +++ b/src/Java/gtPlusPlus/core/inventories/InventoryCircuitProgrammer.java @@ -0,0 +1,173 @@ +package gtPlusPlus.core.inventories; + +import gtPlusPlus.core.recipe.common.CI; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class InventoryCircuitProgrammer implements IInventory{ + + private final String name = "Circuit Programmer"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 26; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt){ + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for(int i = 0;i<list.tagCount();i++){ + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if((slot >= 0) && (slot < INV_SIZE)){ + //Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt){ + final NBTTagList list = new NBTTagList(); + for(int i = 0;i<INV_SIZE;i++){ + final ItemStack stack = this.inventory[i]; + if(stack != null){ + //Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() + { + return this.inventory.length; + } + + public ItemStack[] getInventory(){ + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) + { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) + { + ItemStack stack = this.getStackInSlot(slot); + if(stack != null) + { + if(stack.stackSize > amount) + { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) + { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) + { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) + { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() + { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() + { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() + { + return 64; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() + { + for (int i = 0; i < this.getSizeInventory(); ++i) + { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null){ + //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) + { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return (itemstack.getItem() == CI.getNumberedCircuit(0).getItem()); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java index 8ccf435b46..5cde931822 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java @@ -32,7 +32,10 @@ public class ItemBlockBasicTile extends ItemBlock{ else if (this.mID == 3){ //Project list.add("Scan any crafting recipe in this to mass fabricate them in the Autocrafter.."); } - //super.addInformation(stack, aPlayer, list, bool); + else if (this.mID == 4){ //Circuit Table + list.add("Easy Circuit Configuration."); + } + super.addInformation(stack, aPlayer, list, bool); } diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java index e21e9ffdc6..58c1982af0 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java @@ -16,7 +16,7 @@ public class ItemBlockEntityBase extends ItemBlock { public ItemBlockEntityBase(final Block block) { super(block); this.setMaxDamage(0); - this.setHasSubtypes(true); + //this.setHasSubtypes(true); this.setCreativeTab(AddToCreativeTab.tabMachines); } @@ -33,9 +33,6 @@ public class ItemBlockEntityBase extends ItemBlock { list.add(EnumChatFormatting.GRAY+"Right click with a Screwdriver to change mode."); list.add(EnumChatFormatting.GRAY+"Shift+Right click to view tank information."); } - else if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter){ - //list.add(EnumChatFormatting.GRAY+"A pile of " + materialName + " dust."); - } super.addInformation(stack, aPlayer, list, bool); } diff --git a/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java b/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java new file mode 100644 index 0000000000..252f7d398c --- /dev/null +++ b/src/Java/gtPlusPlus/core/slots/SlotIntegratedCircuit.java @@ -0,0 +1,60 @@ +package gtPlusPlus.core.slots; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import gtPlusPlus.core.recipe.common.CI; + +public class SlotIntegratedCircuit extends Slot { + + public static Item mCircuitItem; + private final short mCircuitLock; + + public SlotIntegratedCircuit(final IInventory inventory, final int slot, final int x, final int y) { + this(Short.MAX_VALUE+1, inventory, slot, x, y); + } + + public SlotIntegratedCircuit(int mTypeLock, final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + if (mTypeLock > Short.MAX_VALUE || mTypeLock < Short.MIN_VALUE) { + mCircuitLock = -1; + } + else { + mCircuitLock = (short) mTypeLock; + } + + + } + + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + boolean isValid = false; + if (mCircuitItem == null) { + mCircuitItem = CI.getNumberedCircuit(0).getItem(); + } + if (mCircuitItem != null) { + if (itemstack != null) { + if (itemstack.getItem() == mCircuitItem) { + + if (mCircuitLock == -1) { + isValid = true; + } + else { + if (itemstack.getItemDamage() == mCircuitLock) { + isValid = true; + } + } + + } + } + } + return isValid; + } + + @Override + public int getSlotStackLimit() { + return 1; + } +} diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java index b1e763c384..e31cb48561 100644 --- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -23,6 +23,7 @@ public class ModTileEntities { GameRegistry.registerTileEntity(TileEntityModularityTable.class, "TileEntityModularityTable"); GameRegistry.registerTileEntity(TileEntityXpConverter.class, "TileEntityXpConverter"); GameRegistry.registerTileEntity(TileEntityGenericSpawner.class, "TileEntityGenericSpawner"); + GameRegistry.registerTileEntity(TileEntityCircuitProgrammer.class, "TileCircuitProgrammer"); //Mod TEs diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java new file mode 100644 index 0000000000..101b2a2c22 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityCircuitProgrammer.java @@ -0,0 +1,400 @@ +package gtPlusPlus.core.tileentities.general; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.InventoryCircuitProgrammer; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraftforge.common.FishingHooks; + +public class TileEntityCircuitProgrammer extends TileEntity implements ISidedInventory { + + private int tickCount = 0; + private boolean isInWater = false; + private final InventoryCircuitProgrammer inventoryContents; + private String customName; + private int locationX; + private int locationY; + private int locationZ; + private int waterSides = 0; + private int baseTickRate = 600 * 5; + + public TileEntityCircuitProgrammer() { + this.inventoryContents = new InventoryCircuitProgrammer();// number of slots - + // without product + // slot + this.setTileLocation(); + } + + public boolean setTileLocation() { + if (this.hasWorldObj()) { + if (!this.getWorldObj().isRemote) { + this.locationX = this.xCoord; + this.locationY = this.yCoord; + this.locationZ = this.zCoord; + return true; + } + } + return false; + } + + public final boolean isSurroundedByWater() { + this.setTileLocation(); + final Block[] surroundingBlocks = new Block[6]; + if (this.hasWorldObj()) { + if (!this.getWorldObj().isRemote) { + surroundingBlocks[0] = this.worldObj.getBlock(this.locationX, this.locationY + 1, this.locationZ); // Above + surroundingBlocks[1] = this.worldObj.getBlock(this.locationX, this.locationY - 1, this.locationZ); // Below + surroundingBlocks[2] = this.worldObj.getBlock(this.locationX + 1, this.locationY, this.locationZ); + surroundingBlocks[3] = this.worldObj.getBlock(this.locationX - 1, this.locationY, this.locationZ); + surroundingBlocks[4] = this.worldObj.getBlock(this.locationX, this.locationY, this.locationZ + 1); + surroundingBlocks[5] = this.worldObj.getBlock(this.locationX, this.locationY, this.locationZ - 1); + int waterCount = 0; + int trapCount = 0; + for (final Block checkBlock : surroundingBlocks) { + if ((checkBlock == Blocks.water) || (checkBlock == Blocks.flowing_water) + || checkBlock.getUnlocalizedName().toLowerCase().contains("water") + || (checkBlock == ModBlocks.blockCircuitProgrammer)) { + if (checkBlock != ModBlocks.blockCircuitProgrammer) { + waterCount++; + } + else { + waterCount++; + trapCount++; + } + } + } + if ((waterCount >= 2) && (trapCount <= 4)) { + this.waterSides = waterCount; + return true; + } + else if ((waterCount >= 2) && (trapCount > 4)) { + Logger.WARNING("Too many fish traps surrounding this one."); + Logger.WARNING("Not adding Loot to the fishtrap at x[" + this.locationX + "] y[" + this.locationY + + "] z[" + this.locationZ + "] (Ticking for loot every " + this.baseTickRate + " ticks)"); + } + } + } + // Utils.LOG_WARNING("Error finding water"); + return false; + } + + public InventoryCircuitProgrammer getInventory() { + return this.inventoryContents; + } + + public boolean tryAddLoot() { + if (this.getInventory().getInventory() != null) { + int checkingSlot = 0; + final ItemStack loot = this.generateLootForCircuitProgrammer().copy(); + try { + //Utils.LOG_WARNING("Trying to add "+loot.getDisplayName()+" | "+loot.getItemDamage()); + for (final ItemStack contents : this.getInventory().getInventory()) { + + + if (GT_Utility.areStacksEqual(loot, contents)){ + if (contents.stackSize < contents.getMaxStackSize()) { + //Utils.LOG_WARNING("3-Trying to add one more "+loot.getDisplayName()+"meta: "+loot.getItemDamage()+" to an existing stack of "+contents.getDisplayName()+" with a size of "+contents.stackSize); + contents.stackSize++; + this.markDirty(); + return true; + } + } + checkingSlot++; + } + checkingSlot = 0; + for (final ItemStack contents : this.getInventory().getInventory()) { + if (contents == null) { + //Utils.LOG_WARNING("Adding Item To Empty Slot. "+(checkingSlot+1)); + this.getInventory().setInventorySlotContents(checkingSlot, loot); + this.markDirty(); + return true; + } + checkingSlot++; + } + } + catch (final NullPointerException n) { + } + } + this.markDirty(); + return false; + } + + private ItemStack generateLootForCircuitProgrammer() { + final int lootWeight = MathUtils.randInt(0, 100); + ItemStack loot; + if (lootWeight <= 5) { + loot = ItemUtils.getSimpleStack(Items.slime_ball); + } + else if (lootWeight <= 10) { + loot = ItemUtils.getSimpleStack(Items.bone); + } + else if (lootWeight <= 15) { + loot = ItemUtils.getSimpleStack(Blocks.sand); + } + else if (lootWeight <= 20) { + loot = ItemUtils.simpleMetaStack(Items.dye, 0, 1); + } + // Junk Loot + else if (lootWeight <= 23) { + if (LoadedMods.PamsHarvestcraft) { + loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken(seaweed, 1); + } + else { + loot = ItemUtils.getSimpleStack(Blocks.dirt); + } + } + // Pam Fish + else if (lootWeight <= 99) { + final Random xstr = new Random(); + loot = FishingHooks.getRandomFishable(xstr, 100); + } + + else if (lootWeight == 100){ + final int rareLoot = MathUtils.randInt(1, 10); + if (rareLoot <= 4) { + loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("nuggetIron", 1); + if (loot == null){ + loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotIron", 1); + } + } + else if (rareLoot <= 7) { + loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("nuggetGold", 1); + if (loot == null){ + loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotGold", 1); + } + } + else if (rareLoot <= 9){ + loot = ItemUtils.getSimpleStack(Items.emerald); + } + else { + loot = ItemUtils.getSimpleStack(Items.diamond); + } + } + else { + loot = ItemUtils.getSimpleStack(Blocks.diamond_ore); + } + loot.stackSize=1; + Logger.WARNING("Adding x"+loot.stackSize+" "+loot.getDisplayName()+"."); + return loot; + } + + @Override + public void updateEntity() { + try{ + if (!this.worldObj.isRemote) { + this.tickCount++; + // Utils.LOG_WARNING("Ticking "+this.tickCount); + // Check if the Tile is within water once per second. + if ((this.tickCount % 20) == 0) { + this.isInWater = this.isSurroundedByWater(); + } + else { + + } + + if (this.isInWater) { + this.calculateTickrate(); + } + + // Try add some loot once every 30 seconds. + if ((this.tickCount % this.baseTickRate) == 0) { + if (this.isInWater) { + // Add loot + // Utils.LOG_WARNING("Adding Loot to the fishtrap at + // x["+this.locationX+"] y["+this.locationY+"] + // z["+this.locationZ+"] (Ticking for loot every + // "+this.baseTickRate+" ticks)"); + this.tryAddLoot(); + this.markDirty(); + } + else { + Logger.WARNING("This Trap does not have enough water around it."); + Logger.WARNING("Not adding Loot to the fishtrap at x[" + this.locationX + "] y[" + this.locationY + + "] z[" + this.locationZ + "] (Ticking for loot every " + this.baseTickRate + " ticks)"); + this.markDirty(); + } + this.tickCount = 0; + } + if (this.tickCount > (this.baseTickRate + 500)) { + this.tickCount = 0; + } + + } + } + catch (final Throwable t){} + } + + public void calculateTickrate() { + int calculateTickrate = 0; + if (this.waterSides <= 2) { + calculateTickrate = 0; + } + else if ((this.waterSides > 2) && (this.waterSides < 4)) { + calculateTickrate = 4800; + } + else if ((this.waterSides >= 4) && (this.waterSides < 6)) { + calculateTickrate = 3600; + } + else if (this.waterSides == 6) { + calculateTickrate = 2400; + } + this.baseTickRate = calculateTickrate; + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + // Utils.LOG_WARNING("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_WARNING("Trying to read NBT data from TE."); + this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + } + + final static String prefix = "food"; + final static String suffix = "raw"; + final static String seaweed = "cropSeaweed"; + final static String greenheartFish = "Greenheartfish"; + private static final String[] harvestcraftFish = { "Anchovy", "Bass", "Carp", "Catfish", "Charr", "Clam", "Crab", + "Crayfish", "Eel", "Frog", "Grouper", "Herring", "Jellyfish", "Mudfish", "Octopus", "Perch", "Scallop", + "Shrimp", "Snail", "Snapper", "Tilapia", "Trout", "Tuna", "Turtle", "Walleye" }; + + public static void pamsHarvestCraftCompat() { + for (int i = 0; i < harvestcraftFish.length; i++) { + + } + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return this.getInventory().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().openInventory(); + } + + @Override + public void closeInventory() { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + this.getInventory().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; + for (int r=0; r<this.getInventory().getSizeInventory(); r++){ + accessibleSides[r]=r; + } + return accessibleSides; + + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return true; + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.fishtrap"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java index 148895e2c0..f2a6844053 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java @@ -1,6 +1,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced; import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; @@ -67,15 +68,15 @@ public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_Fus } public String[] getDescription() { + String aTierName = GT_Values.VN[9]; return new String[]{ "HARNESSING THE POWER OF A NEUTRON STAR", "Fusion Machine Casings MK III around Advanced Fusion Coils", "2-16 Input Hatches", "1-16 Output Hatches", "1-16 Energy Hatches", - "All Hatches must be UV or better", + "All Hatches must be "+aTierName+" or better", "32768 EU/t and 80mio EU Cap per Energy Hatch", - "Causes " + 20 * this.getPollutionPerTick(null) + " Pollution per second", CORE.GT_Tooltip}; } diff --git a/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_GRATE_A.png b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_GRATE_A.png Binary files differnew file mode 100644 index 0000000000..50be701a0b --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_GRATE_A.png diff --git a/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_PANEL_F.png b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_PANEL_F.png Binary files differnew file mode 100644 index 0000000000..f7c77011cc --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_PANEL_F.png diff --git a/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_PANEL_G.png b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_PANEL_G.png Binary files differnew file mode 100644 index 0000000000..172fab4657 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_PANEL_G.png diff --git a/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_PANEL_H.png b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_PANEL_H.png Binary files differnew file mode 100644 index 0000000000..68ab46a03d --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_PANEL_H.png diff --git a/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_PANEL_I.png b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_PANEL_I.png Binary files differnew file mode 100644 index 0000000000..4443dc8024 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_METAL_PANEL_I.png diff --git a/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_TECH_PANEL_B.png b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_TECH_PANEL_B.png Binary files differnew file mode 100644 index 0000000000..60864acea3 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_TECH_PANEL_B.png diff --git a/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_TECH_PANEL_C.png b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_TECH_PANEL_C.png Binary files differnew file mode 100644 index 0000000000..15e1362563 --- /dev/null +++ b/src/resources/assets/miscutils/textures/blocks/metro/TEXTURE_TECH_PANEL_C.png diff --git a/src/resources/assets/miscutils/textures/gui/CircuitProgrammer.png b/src/resources/assets/miscutils/textures/gui/CircuitProgrammer.png Binary files differnew file mode 100644 index 0000000000..d9f9c8b95a --- /dev/null +++ b/src/resources/assets/miscutils/textures/gui/CircuitProgrammer.png |