Jump to content

galaxyblast

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by galaxyblast

  1. My generator is set to send energy out to whatever is next to it and implements IEnergyReceiver. I'm not sure whether or not the pipe also tries to take energy from the generator on it's own. The pipes I'm using are from Thermal Dynamics and I can't seem to find the source for it to check. Though even if I don't use pipes, when I reload the world the GUI doesn't show how much RF is stored, even though there is some there.
  2. package com.galaxyblast.advancedciv.blocks.containers; import com.galaxyblast.advancedciv.tileentity.MagGenTileEntity; import com.galaxyblast.advancedciv.utils.SuperCraftingManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.world.World; public class ContainerMagGen extends Container { private MagGenTileEntity te; private World worldObj; public ContainerMagGen(InventoryPlayer playerInv, MagGenTileEntity teIn) { this.te = teIn; this.worldObj = playerInv.player.worldObj; //Magnet this.addSlotToContainer(new Slot(this.te, 0, 80, 35)); //Upgrades for (int y = 0; y < 3; ++y) { for (int x = 0; x < 1; ++x) { this.addSlotToContainer(new Slot(this.te, x + y + 1, 153 + x * 18, 15 + y * 18)); } } //Player inventory for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } //Player Hotbar for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(playerInv, x, 8 + x * 18, 142)); } } @Override public boolean canInteractWith(EntityPlayer player) { return this.te.isUseableByPlayer(player); } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) { ItemStack previous = null; Slot slot = (Slot) this.inventorySlots.get(fromSlot); if (slot != null && slot.getHasStack()) { ItemStack current = slot.getStack(); previous = current.copy(); if (fromSlot < 4) { // From TE Inventory to Player Inventory if (!this.mergeItemStack(current, 4, 40, true)) return null; } else { // From Player Inventory to TE Inventory if (!this.mergeItemStack(current, 0, 4, false)) return null; } if (current.stackSize == 0) slot.putStack((ItemStack) null); else slot.onSlotChanged(); if (current.stackSize == previous.stackSize) return null; slot.onPickupFromSlot(playerIn, current); } return previous; } }
  3. Okay, so I've been working on a mod using the Redstone Flux API (and a few other mods), and until recently I thought I had everything working. I've tried everything I can think of trying to fix this, but I have no clue. There is one main problem, my Generators' GUI only updates the energy bar when one of 2 things are happening. If it's generating energy, or has an actual machine placed next to it. Also, while the tile keeps it's energy upon quitting, when the world is reloaded the energy bar shows 0, even though the energy is still there. If I put down my generator and start it, then place a machine directly next to it, the energy updates properly, but if I connect a cable/pipe to it, the energy will transfer, but the generator's GUI won't show it transferring. Without pipes With pipes I've tried added System.out.print to the tile's update to see what the energy is doing, and if I use a pipe to extract the energy it will print 2 messages, 0 and whatever the energy used to be. Here is my TileEntity code (warning, since I've been trying everything I can think of, it's a little messy) package com.galaxyblast.advancedciv.tileentity; import com.galaxyblast.advancedciv.ModItems; import cofh.api.energy.EnergyStorage; import cofh.api.energy.IEnergyHandler; import cofh.api.energy.IEnergyReceiver; import cofh.api.energy.IEnergyStorage; import cofh.core.block.TileCoFHBase; import cpw.mods.fml.relauncher.Side; 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; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; public class MagGenTileEntity extends TileCoFHBase implements IEnergyHandler, IEnergyStorage, IInventory { private int capacity = 20000; private int maxExtract = 100; private int energy; private ItemStack[] inventory = new ItemStack[4]; private String name; private float cooldown; private EnergyStorage storage = new EnergyStorage(this.capacity);; public MagGenTileEntity() { this.cooldown = 0.0F; } public EnergyStorage getStorage() { return this.storage; } @Override public boolean canConnectEnergy(ForgeDirection from) { return true; } @Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { return this.receiveEnergy(maxReceive, simulate); } @Override public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { return this.extractEnergy(maxExtract, simulate); } @Override public int getEnergyStored(ForgeDirection from) { return this.getEnergyStored(); } @Override public int getMaxEnergyStored(ForgeDirection from) { return this.getMaxEnergyStored(); } public final void setEnergyStored(int par1) { this.setEnergyStored(par1); } @Override public int getSizeInventory() { return this.inventory.length; } @Override public ItemStack getStackInSlot(int slot) { if (slot < 0 || slot >= this.getSizeInventory()) return null; return this.inventory[slot]; } @Override public ItemStack decrStackSize(int index, int count) { if (this.getStackInSlot(index) != null) { ItemStack itemstack; if (this.getStackInSlot(index).stackSize <= count) { itemstack = this.getStackInSlot(index); this.setInventorySlotContents(index, null); this.markDirty(); return itemstack; } else { itemstack = this.getStackInSlot(index).splitStack(count); if (this.getStackInSlot(index).stackSize <= 0) { this.setInventorySlotContents(index, null); } else { // Just to show that changes happened this.setInventorySlotContents(index, this.getStackInSlot(index)); } this.markDirty(); return itemstack; } } else { return null; } } @Override public ItemStack getStackInSlotOnClosing(int slot) { if (this.inventory[slot] != null) { ItemStack itemstack = this.inventory[slot]; this.inventory[slot] = null; return itemstack; } else return null; } @Override public void setInventorySlotContents(int slot, ItemStack itemstack) { this.inventory[slot] = itemstack; if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { itemstack.stackSize = this.getInventoryStackLimit(); } } @Override public String getInventoryName() { return "Electromagnetic Induction Generator"; } @Override public boolean hasCustomInventoryName() { return false; } @Override public int getInventoryStackLimit() { return 1; } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); //this.storage.writeToNBT(nbt); nbt.setInteger("Energy", this.storage.getEnergyStored()); this.storage.writeToNBT(nbt); NBTTagList list = new NBTTagList(); for (int i = 0; i < this.getSizeInventory(); ++i) { if (this.getStackInSlot(i) != null) { NBTTagCompound stackTag = new NBTTagCompound(); stackTag.setByte("Slot", (byte) i); this.getStackInSlot(i).writeToNBT(stackTag); list.appendTag(stackTag); } } nbt.setTag("Items", list); if (this.hasCustomInventoryName()) { nbt.setString("CustomName", this.getInventoryName()); } } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); //this.storage.readFromNBT(nbt); this.storage.readFromNBT(nbt); if(this.storage.getEnergyStored() > this.storage.getMaxEnergyStored()) this.storage.setEnergyStored(this.storage.getMaxEnergyStored()); NBTTagList list = nbt.getTagList("Items", 10); for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound stackTag = list.getCompoundTagAt(i); int slot = stackTag.getByte("Slot") & 255; this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag)); } if (nbt.hasKey("CustomName", ) { this.name = nbt.getString("CustomName"); } } @Override public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double) this.xCoord - 0.5D, (double) this.yCoord - 0.5D, (double) this.zCoord - 0.5D) <= 64.0D; } @Override public void openInventory() { // TODO Auto-generated method stub } @Override public void closeInventory() { // TODO Auto-generated method stub } @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { return false; } @Override public int receiveEnergy(int maxReceive, boolean simulate) { return this.storage.receiveEnergy(maxReceive, simulate); } @Override public int extractEnergy(int maxExtract, boolean simulate) { return this.storage.extractEnergy(maxExtract, simulate); } @Override public int getEnergyStored() { return this.storage.getEnergyStored(); } @Override public int getMaxEnergyStored() { return this.storage.getMaxEnergyStored(); } public int getEnergyScaled() { return (int)(40.0F * (float)this.getEnergyStored() / (float)this.getMaxEnergyStored()); } @Override public void updateEntity() { super.updateEntity(); if(this.getEnergyStored() > 0) this.transmitEnergy(); if(this.getStackInSlot(0) != null && this.getStackInSlot(0).getItem() == ModItems.magnet) { if(this.getStackInSlot(0).getItemDamage() == 0) this.receiveEnergy(5, false); else if(this.getStackInSlot(0).getItemDamage() == 1) this.receiveEnergy(100, false); else if(this.getStackInSlot(0).getItemDamage() == 2) { if(this.getStackInSlot(3) != null && this.getStackInSlot(3).getItem() == ModItems.coolingUpgrade && this.getStackInSlot(3).getItemDamage() == 2) this.receiveEnergy(5000, false); } } if(this.getStackInSlot(1) != null && this.getStackInSlot(1).getItem() == ModItems.outputUpgrade) { int type = this.getStackInSlot(1).getItemDamage(); if(type == 0) this.maxExtract = 1000; else if(type == 1) this.maxExtract = 5000; else if(type == 2) this.maxExtract = 25000; } else if(this.getStackInSlot(1) == null) this.maxExtract = 100; this.storage.setMaxExtract(this.maxExtract); sendUpdatePacket(Side.CLIENT); System.out.print(this.getEnergyStored() + "\n"); } private void transmitEnergy() { for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = this.worldObj.getTileEntity(this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ); if (!(tile instanceof MagGenTileEntity)) { if ((tile instanceof IEnergyReceiver)) { this.getStorage().extractEnergy(((IEnergyReceiver) tile).receiveEnergy(side.getOpposite(), getStorage().extractEnergy(this.maxExtract, true), false), false); } } } } public String getName() { // TODO Auto-generated method stub return null; } public int getType() { // TODO Auto-generated method stub return 0; } } And here's my GUI code package com.galaxyblast.advancedciv.gui; import java.util.List; import org.lwjgl.opengl.GL11; import com.galaxyblast.advancedciv.AdvancedCivilizations; import com.galaxyblast.advancedciv.blocks.containers.ContainerMagGen; import com.galaxyblast.advancedciv.tileentity.MagGenTileEntity; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.util.ResourceLocation; public class GuiMagGen extends GuiContainer { private static final ResourceLocation ui = new ResourceLocation(AdvancedCivilizations.MODID, "textures/gui/magGen.png"); private static final ResourceLocation progress = new ResourceLocation(AdvancedCivilizations.MODID, "textures/gui/energyBar.png"); private MagGenTileEntity tile; public GuiMagGen(InventoryPlayer playerInv, MagGenTileEntity te) { super(new ContainerMagGen(playerInv, te)); this.xSize = 176; this.ySize = 166; this.tile = te; } @Override protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { this.fontRendererObj.drawString("EIG", 80, 6, 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); this.fontRendererObj.drawString(this.tile.getEnergyStored() + " RF", 9, 14, 4210752); //System.out.print("X: " + String.valueOf(this.tile.xCoord) + "Y: " + String.valueOf(this.tile.yCoord) + "Z: " + String.valueOf(this.tile.zCoord) + "\n"); } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(ui); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.mc.getTextureManager().bindTexture(progress); int energy = this.tile.getEnergyScaled(); k = (this.width - 156) / 2; l = (this.height - 122 + ((41 - energy) * 2)) / 2; this.drawTexturedModalRect(k, l, 0, 0, 12, energy); } }
  4. private void calculateCurrentChanges(World par1World, int par2, int par3, int par4, int par5, int par6, int par7) { int var8 = par1World.getBlockMetadata(par2, par3, par4); int var9 = 0; this.wiresProvidePower = false; boolean var10 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4); this.wiresProvidePower = true; int var11; int var12; int var13; if (var10) { var9 = 35; //<------------------ This was originally 15, i figured this was were it declared the max strength } else { for (var11 = 0; var11 < 4; ++var11) { var12 = par2; var13 = par4; if (var11 == 0) { var12 = par2 - 1; } if (var11 == 1) { ++var12; } if (var11 == 2) { var13 = par4 - 1; } if (var11 == 3) { ++var13; } if (var12 != par5 || par3 != par6 || var13 != par7) { var9 = this.getMaxCurrentStrength(par1World, var12, par3, var13, var9); } if (par1World.isBlockNormalCube(var12, par3, var13) && !par1World.isBlockNormalCube(par2, par3 + 1, par4)) { if (var12 != par5 || par3 + 1 != par6 || var13 != par7) { var9 = this.getMaxCurrentStrength(par1World, var12, par3 + 1, var13, var9); } } else if (!par1World.isBlockNormalCube(var12, par3, var13) && (var12 != par5 || par3 - 1 != par6 || var13 != par7)) { var9 = this.getMaxCurrentStrength(par1World, var12, par3 - 1, var13, var9); } } if (var9 > 0) { --var9; } else { var9 = 0; } } if (var8 != var9) { par1World.editingBlocks = true; par1World.setBlockMetadataWithNotify(par2, par3, par4, var9); par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4); par1World.editingBlocks = false; for (var11 = 0; var11 < 4; ++var11) { var12 = par2; var13 = par4; int var14 = par3 - 1; if (var11 == 0) { var12 = par2 - 1; } if (var11 == 1) { ++var12; } if (var11 == 2) { var13 = par4 - 1; } if (var11 == 3) { ++var13; } if (par1World.isBlockNormalCube(var12, par3, var13)) { var14 += 2; } boolean var15 = false; int var16 = this.getMaxCurrentStrength(par1World, var12, par3, var13, -1); var9 = par1World.getBlockMetadata(par2, par3, par4); if (var9 > 0) { --var9; } if (var16 >= 0 && var16 != var9) { this.calculateCurrentChanges(par1World, var12, par3, var13, par2, par3, par4); } var16 = this.getMaxCurrentStrength(par1World, var12, var14, var13, -1); var9 = par1World.getBlockMetadata(par2, par3, par4); if (var9 > 0) { --var9; } if (var16 >= 0 && var16 != var9) { this.calculateCurrentChanges(par1World, var12, var14, var13, par2, par3, par4); } } if (var8 < var9 || var9 == 0) { this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3, par4)); this.blocksNeedingUpdate.add(new ChunkPosition(par2 - 1, par3, par4)); this.blocksNeedingUpdate.add(new ChunkPosition(par2 + 1, par3, par4)); this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3 - 1, par4)); this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3 + 1, par4)); this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3, par4 - 1)); this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3, par4 + 1)); } } }
  5. OK, so I'm adding a new redstone wire that has a longer charge, I used the original redstone wire code and I think I found were it declares the length of the charge, but when I lengthen it, it doesn't have a charge, not even 1 block. Here is my code: package net.minecraft.src; import cpw.mods.fml.common.Side; import cpw.mods.fml.common.asm.SideOnly; import java.util.ArrayList; import java.util.HashSet; import java.util.Random; import java.util.Set; public class IronWire extends Block { public boolean wiresProvidePower = true; public Set blocksNeedingUpdate = new HashSet(); public IronWire(int var1, int var2) { super(var1, var2, Material.circuits); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); } public int getBlockTextureFromSideAndMetadata(int par1, int par2) { return this.blockIndexInTexture; } public boolean canConnectRedstone(IBlockAccess iba, int i, int j, int k, int dir) { return true; } /** * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been * cleared to be reused) */ public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return null; } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return false; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return false; } /** * The type of render function that is called for this block */ public int getRenderType() { return 40; } /** * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z */ public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) { return par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) || par1World.getBlockId(par2, par3 - 1, par4) == Block.glowStone.blockID; } /** * Sets the strength of the wire current (0-15) for this block based on neighboring blocks and propagates to * neighboring redstone wires */ private void updateAndPropagateCurrentStrength(World par1World, int par2, int par3, int par4) { this.calculateCurrentChanges(par1World, par2, par3, par4, par2, par3, par4); ArrayList var5 = new ArrayList(this.blocksNeedingUpdate); this.blocksNeedingUpdate.clear(); for (int var6 = 0; var6 < (var5.size()); ++var6) { ChunkPosition var7 = (ChunkPosition)var5.get(var6); par1World.notifyBlocksOfNeighborChange(var7.x, var7.y, var7.z, this.blockID); } } private void calculateCurrentChanges(World par1World, int par2, int par3, int par4, int par5, int par6, int par7) { int var8 = par1World.getBlockMetadata(par2, par3, par4); int var9 = 0; this.wiresProvidePower = false; boolean var10 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4); this.wiresProvidePower = true; int var11; int var12; int var13; if (var10) { var9 = 35; } else { for (var11 = 0; var11 < 4; ++var11) { var12 = par2; var13 = par4; if (var11 == 0) { var12 = par2 - 1; } if (var11 == 1) { ++var12; } if (var11 == 2) { var13 = par4 - 1; } if (var11 == 3) { ++var13; } if (var12 != par5 || par3 != par6 || var13 != par7) { var9 = this.getMaxCurrentStrength(par1World, var12, par3, var13, var9); } if (par1World.isBlockNormalCube(var12, par3, var13) && !par1World.isBlockNormalCube(par2, par3 + 1, par4)) { if (var12 != par5 || par3 + 1 != par6 || var13 != par7) { var9 = this.getMaxCurrentStrength(par1World, var12, par3 + 1, var13, var9); } } else if (!par1World.isBlockNormalCube(var12, par3, var13) && (var12 != par5 || par3 - 1 != par6 || var13 != par7)) { var9 = this.getMaxCurrentStrength(par1World, var12, par3 - 1, var13, var9); } } if (var9 > 0) { --var9; } else { var9 = 0; } } if (var8 != var9) { par1World.editingBlocks = true; par1World.setBlockMetadataWithNotify(par2, par3, par4, var9); par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4); par1World.editingBlocks = false; for (var11 = 0; var11 < 4; ++var11) { var12 = par2; var13 = par4; int var14 = par3 - 1; if (var11 == 0) { var12 = par2 - 1; } if (var11 == 1) { ++var12; } if (var11 == 2) { var13 = par4 - 1; } if (var11 == 3) { ++var13; } if (par1World.isBlockNormalCube(var12, par3, var13)) { var14 += 2; } boolean var15 = false; int var16 = this.getMaxCurrentStrength(par1World, var12, par3, var13, -1); var9 = par1World.getBlockMetadata(par2, par3, par4); if (var9 > 0) { --var9; } if (var16 >= 0 && var16 != var9) { this.calculateCurrentChanges(par1World, var12, par3, var13, par2, par3, par4); } var16 = this.getMaxCurrentStrength(par1World, var12, var14, var13, -1); var9 = par1World.getBlockMetadata(par2, par3, par4); if (var9 > 0) { --var9; } if (var16 >= 0 && var16 != var9) { this.calculateCurrentChanges(par1World, var12, var14, var13, par2, par3, par4); } } if (var8 < var9 || var9 == 0) { this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3, par4)); this.blocksNeedingUpdate.add(new ChunkPosition(par2 - 1, par3, par4)); this.blocksNeedingUpdate.add(new ChunkPosition(par2 + 1, par3, par4)); this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3 - 1, par4)); this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3 + 1, par4)); this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3, par4 - 1)); this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3, par4 + 1)); } } } /** * Calls World.notifyBlocksOfNeighborChange() for all neighboring blocks, but only if the given block is a redstone * wire. */ private void notifyWireNeighborsOfNeighborChange(World par1World, int par2, int par3, int par4) { if (par1World.getBlockId(par2, par3, par4) == this.blockID) { par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID); par1World.notifyBlocksOfNeighborChange(par2 - 1, par3, par4, this.blockID); par1World.notifyBlocksOfNeighborChange(par2 + 1, par3, par4, this.blockID); par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - 1, this.blockID); par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + 1, this.blockID); par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID); par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID); } } /** * Called whenever the block is added into the world. Args: world, x, y, z */ public void onBlockAdded(World par1World, int par2, int par3, int par4) { super.onBlockAdded(par1World, par2, par3, par4); if (!par1World.isRemote) { this.updateAndPropagateCurrentStrength(par1World, par2, par3, par4); par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID); par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID); this.notifyWireNeighborsOfNeighborChange(par1World, par2 - 1, par3, par4); this.notifyWireNeighborsOfNeighborChange(par1World, par2 + 1, par3, par4); this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3, par4 - 1); this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3, par4 + 1); if (par1World.isBlockNormalCube(par2 - 1, par3, par4)) { this.notifyWireNeighborsOfNeighborChange(par1World, par2 - 1, par3 + 1, par4); } else { this.notifyWireNeighborsOfNeighborChange(par1World, par2 - 1, par3 - 1, par4); } if (par1World.isBlockNormalCube(par2 + 1, par3, par4)) { this.notifyWireNeighborsOfNeighborChange(par1World, par2 + 1, par3 + 1, par4); } else { this.notifyWireNeighborsOfNeighborChange(par1World, par2 + 1, par3 - 1, par4); } if (par1World.isBlockNormalCube(par2, par3, par4 - 1)) { this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 + 1, par4 - 1); } else { this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 - 1, par4 - 1); } if (par1World.isBlockNormalCube(par2, par3, par4 + 1)) { this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 + 1, par4 + 1); } else { this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 - 1, par4 + 1); } } } /** * ejects contained items into the world, and notifies neighbours of an update, as appropriate */ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { super.breakBlock(par1World, par2, par3, par4, par5, par6); if (!par1World.isRemote) { par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID); par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID); par1World.notifyBlocksOfNeighborChange(par2 + 1, par3, par4, this.blockID); par1World.notifyBlocksOfNeighborChange(par2 - 1, par3, par4, this.blockID); par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + 1, this.blockID); par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - 1, this.blockID); this.updateAndPropagateCurrentStrength(par1World, par2, par3, par4); this.notifyWireNeighborsOfNeighborChange(par1World, par2 - 1, par3, par4); this.notifyWireNeighborsOfNeighborChange(par1World, par2 + 1, par3, par4); this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3, par4 - 1); this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3, par4 + 1); if (par1World.isBlockNormalCube(par2 - 1, par3, par4)) { this.notifyWireNeighborsOfNeighborChange(par1World, par2 - 1, par3 + 1, par4); } else { this.notifyWireNeighborsOfNeighborChange(par1World, par2 - 1, par3 - 1, par4); } if (par1World.isBlockNormalCube(par2 + 1, par3, par4)) { this.notifyWireNeighborsOfNeighborChange(par1World, par2 + 1, par3 + 1, par4); } else { this.notifyWireNeighborsOfNeighborChange(par1World, par2 + 1, par3 - 1, par4); } if (par1World.isBlockNormalCube(par2, par3, par4 - 1)) { this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 + 1, par4 - 1); } else { this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 - 1, par4 - 1); } if (par1World.isBlockNormalCube(par2, par3, par4 + 1)) { this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 + 1, par4 + 1); } else { this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 - 1, par4 + 1); } } } /** * Returns the current strength at the specified block if it is greater than the passed value, or the passed value * otherwise. Signature: (world, x, y, z, strength) */ private int getMaxCurrentStrength(World par1World, int par2, int par3, int par4, int par5) { if (par1World.getBlockId(par2, par3, par4) != this.blockID) { return par5; } else { int var6 = par1World.getBlockMetadata(par2, par3, par4); return var6 > par5 ? var6 : par5; } } /** * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are * their own) Args: x, y, z, neighbor blockID */ public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) { if (!par1World.isRemote) { int var6 = par1World.getBlockMetadata(par2, par3, par4); boolean var7 = this.canPlaceBlockAt(par1World, par2, par3, par4); if (var7) { this.updateAndPropagateCurrentStrength(par1World, par2, par3, par4); } else { this.dropBlockAsItem(par1World, par2, par3, par4, var6, 0); par1World.setBlockWithNotify(par2, par3, par4, 0); } super.onNeighborBlockChange(par1World, par2, par3, par4, par5); } } /** * Returns the ID of the items to drop on destruction. */ public int idDropped(int par1, Random par2Random, int par3) { return WarInit.ironwire.shiftedIndex; } /** * Returns true if the block is emitting direct/strong redstone power on the specified side. Args: World, X, Y, Z, * side */ public boolean isProvidingStrongPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { return !this.wiresProvidePower ? false : this.isProvidingWeakPower(par1IBlockAccess, par2, par3, par4, par5); } /** * Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube * returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X, * Y, Z, side */ public boolean isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { if (!this.wiresProvidePower) { return false; } else if (par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 0) { return false; } else if (par5 == 1) { return true; } else { boolean var6 = isPoweredOrRepeater(par1IBlockAccess, par2 - 1, par3, par4, 1) || !par1IBlockAccess.isBlockNormalCube(par2 - 1, par3, par4) && isPoweredOrRepeater(par1IBlockAccess, par2 - 1, par3 - 1, par4, -1); boolean var7 = isPoweredOrRepeater(par1IBlockAccess, par2 + 1, par3, par4, 3) || !par1IBlockAccess.isBlockNormalCube(par2 + 1, par3, par4) && isPoweredOrRepeater(par1IBlockAccess, par2 + 1, par3 - 1, par4, -1); boolean var8 = isPoweredOrRepeater(par1IBlockAccess, par2, par3, par4 - 1, 2) || !par1IBlockAccess.isBlockNormalCube(par2, par3, par4 - 1) && isPoweredOrRepeater(par1IBlockAccess, par2, par3 - 1, par4 - 1, -1); boolean var9 = isPoweredOrRepeater(par1IBlockAccess, par2, par3, par4 + 1, 0) || !par1IBlockAccess.isBlockNormalCube(par2, par3, par4 + 1) && isPoweredOrRepeater(par1IBlockAccess, par2, par3 - 1, par4 + 1, -1); if (!par1IBlockAccess.isBlockNormalCube(par2, par3 + 1, par4)) { if (par1IBlockAccess.isBlockNormalCube(par2 - 1, par3, par4) && isPoweredOrRepeater(par1IBlockAccess, par2 - 1, par3 + 1, par4, -1)) { var6 = true; } if (par1IBlockAccess.isBlockNormalCube(par2 + 1, par3, par4) && isPoweredOrRepeater(par1IBlockAccess, par2 + 1, par3 + 1, par4, -1)) { var7 = true; } if (par1IBlockAccess.isBlockNormalCube(par2, par3, par4 - 1) && isPoweredOrRepeater(par1IBlockAccess, par2, par3 + 1, par4 - 1, -1)) { var8 = true; } if (par1IBlockAccess.isBlockNormalCube(par2, par3, par4 + 1) && isPoweredOrRepeater(par1IBlockAccess, par2, par3 + 1, par4 + 1, -1)) { var9 = true; } } return !var8 && !var7 && !var6 && !var9 && par5 >= 2 && par5 <= 5 ? true : (par5 == 2 && var8 && !var6 && !var7 ? true : (par5 == 3 && var9 && !var6 && !var7 ? true : (par5 == 4 && var6 && !var8 && !var9 ? true : par5 == 5 && var7 && !var8 && !var9))); } } /** * Can this block provide power. Only wire currently seems to have this change based on its state. */ public boolean canProvidePower() { return this.wiresProvidePower; } @SideOnly(Side.CLIENT) /** * A randomly called display update to be able to add particles or other items for display */ public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { int var6 = par1World.getBlockMetadata(par2, par3, par4); if (var6 > 0) { double var7 = (double)par2 + 0.5D + ((double)par5Random.nextFloat() - 0.5D) * 0.2D; double var9 = (double)((float)par3 + 0.0625F); double var11 = (double)par4 + 0.5D + ((double)par5Random.nextFloat() - 0.5D) * 0.2D; float var13 = (float)var6 / 15.0F; float var14 = var13 * 0.6F + 0.4F; if (var6 == 0) { var14 = 0.0F; } float var15 = var13 * var13 * 0.7F - 0.5F; float var16 = var13 * var13 * 0.6F - 0.7F; if (var15 < 0.0F) { var15 = 0.0F; } if (var16 < 0.0F) { var16 = 0.0F; } par1World.spawnParticle("reddust", var7, var9, var11, (double)var14, (double)var15, (double)var16); } } /** * Returns true if the block coordinate passed can provide power, or is a redstone wire. */ public static boolean isPowerProviderOrWire(IBlockAccess par0IBlockAccess, int par1, int par2, int par3, int par4) { int var5 = par0IBlockAccess.getBlockId(par1, par2, par3); if (var5 == WarInit.IronWire1.blockID) { return true; } else if (var5 == 0) { return false; } else if (var5 != Block.redstoneRepeaterIdle.blockID && var5 != Block.redstoneRepeaterActive.blockID) { return (Block.blocksList[var5] != null && Block.blocksList[var5].canConnectRedstone(par0IBlockAccess, par1, par2, par3, par4)); } else { int var6 = par0IBlockAccess.getBlockMetadata(par1, par2, par3); return par4 == (var6 & 3) || par4 == Direction.footInvisibleFaceRemap[var6 & 3]; } } /** * Returns true if the block coordinate passed can provide power, or is a redstone wire, or if its a repeater that * is powered. */ public static boolean isPoweredOrRepeater(IBlockAccess par0IBlockAccess, int par1, int par2, int par3, int par4) { if (isPowerProviderOrWire(par0IBlockAccess, par1, par2, par3, par4)) { return true; } else { int var5 = par0IBlockAccess.getBlockId(par1, par2, par3); if (var5 == Block.redstoneRepeaterActive.blockID) { int var6 = par0IBlockAccess.getBlockMetadata(par1, par2, par3); return par4 == (var6 & 3); } else { return false; } } } @SideOnly(Side.CLIENT) /** * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative) */ public int idPicked(World par1World, int par2, int par3, int par4) { return WarInit.ironwire.shiftedIndex; } public String getTextureFile() { return "/warimg/terrain.png"; } } Also when it gets powered it doesn't light up, any help with that?
  6. OK so I'm working on a mod that has magic tools in it. For many of the magic abilities I don't even know where to start. I'll start with the easiest, the Bow. I want the bow to start out as just the handle, then when you switch to it the bow extends out and puts itself together. With this one my only problem is I don't know how to change the texture upon the user switching to the bow. Next is the pick, I want the pick to be run off a charge, and as the charge goes down the pick has less effectiveness (I already know how to do this). But then when you are within 10 blocks of a magic block the pick will start charging back up. And If fully charged you can hold right-click for a couple seconds and the pick will dis-charge entirely and destroy all stone/netherrack blocks within a 25 block radius. Lastly is the sword. For this one I want it so when its fully charged, you can hold right click for a couple seconds, then the sword will hit and you will hear a click, then if you right click again you will hear an explosion and it will kill all hostile mobs within a 100 block radius. All I need help on is I don't know how to: A) make the bow change textures upon being switched to B) make the pick destroy all stone/netherrack blocks within a 25 block radius C) make the sword kill all hostile mobs within a 100 block radius.
  7. I fixed the server and everything, it loads up now. I just had to move the PreloadTextures thing into a different function and it worked fine. But now when I try to join it I the client crashes. Here is the error log:
  8. Ok, now it gives me a different error. I made the change for the tools and the armor and I also fixed one error myself. Here is the new mod_MagicTools: And i did reset the base files back to their original code. Also, like I said before when I try to load up a server with only forge installed it gets stuck on "MinecraftForge v4.0.0.228 Initialized"
  9. Ok so I am making a big mod and I have broken it down into parts. This is the MagicTools piece of it and it works fine on single player, but when I try multiplayer it crashes? Also even with only forge in the minecraft_server.jar it never starts up completely, it only gets to 2 mods loaded? Anyway, here is the error code i get: and here are the mod files: EnumToolMaterial: mod_MagicTools MagicArmor MagicAxe MagicHoe MagicItem MagicPick MagicSpade MagicSword And I know its probably something blaintly obvious that I missed, but this is the first time I've ever tried SMP modding and there I couldn't find an updated tutorial to save my life. Please help.
  10. well thanks for trying, I'll try posting on the minecraftforums, see if anyone there could help.
  11. Well, after looking around through RenderPlayer I found were it actually renders out the players. I've been trying to us an if statement to check whether or not your wearing the helm of darkness. But now if I make any form of attempt to look at my guy the game crashes. I'm assuming I'm doing something wrong. Here is the code from RenderPlayer:
  12. Ok so I'm trying to add Hades' Helm of Darkness and camouflage armor to my mod and the helm will make the player completely invisible for a short period of time and the camouflage armor will remove the player's nameplate. However I have no idea how to do this. I've been searching Google for a while now looking for anything relatively close to this. If anyone could help me out and NOT spoon-feed me I will be VERY grateful. Also, if there is a way to make it so the helm doesn't take damage from weapons could you guys tell me. Cause i want it so it has 100 durability and takes 1 point of damages per 10 seconds while invisible and once it hits 0 it breaks. But i don't want weapons to damage it at all. I suppose this isn't entirely necessary, but I would like it. Those first two things are what I would like help with the most.
  13. Thank you so much! But now it just can't find Block implements ITextureProvider
  14. Please help, every time I try to recompile my mod I get the same error. Here is my mod files mod_BuildingBlocks.java BuildingBlocks I've looked everywhere for an answer to this for the past hour, I just can't find it anywhere. I think its because it can't find net.minecraft.src.forge.*; but I can't figure out how to fix it. Please help.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.