Posted July 20, 201312 yr Hello, I am trying to make cables for my mod Electricraft. I have it set up to where the block detects if there is cables around it but I don't know how to detect if energy is needed and get energy from the other cables in the network Block Code: package com.electricraft.core.block; import java.util.Random; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class BlockCable extends BlockContainer { public BlockCable(int id, Material mat) { super(id, mat); this.needsRandomTick = true; } public void randomDisplayTick(World w, int x, int y, int z, Random r) { TileEntityCable below; if(w.getBlockTileEntity(x, y-1, z) instanceof TileEntityCable) { below = (TileEntityCable) w.getBlockTileEntity(x, y-1, z); } TileEntityCable above; if(w.getBlockTileEntity(x, y+1, z) instanceof TileEntityCable) { above = (TileEntityCable) w.getBlockTileEntity(x, y+1, z); } TileEntityCable plusX; if(w.getBlockTileEntity(x+1, y, z) instanceof TileEntityCable) { plusX = (TileEntityCable) w.getBlockTileEntity(x+1, y, z); } TileEntityCable minusX; if(w.getBlockTileEntity(x-1, y, z) instanceof TileEntityCable) { minusX = (TileEntityCable) w.getBlockTileEntity(x-1, y, z); } TileEntityCable plusZ; if(w.getBlockTileEntity(x, y, z+1) instanceof TileEntityCable) { plusZ = (TileEntityCable) w.getBlockTileEntity(x, y, z+1); } TileEntityCable minusZ; if(w.getBlockTileEntity(x, y, z-1) instanceof TileEntityCable) { minusZ = (TileEntityCable) w.getBlockTileEntity(x, y, z-1); } } public TileEntity createNewTileEntity(World w) { return new TileEntityCable(); } } Tile Entity Code: package com.electricraft.core.block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; public class TileEntityCable extends TileEntity { public boolean isEnergyRequired; public boolean hasEnergy; public void readFromNBT(NBTTagCompound nbt) { } public void writeToNBT(NBTTagCompound nbt) { } }
July 21, 201312 yr Look into how the Universal Electricity works, it's open source If you guys dont get it.. then well ya.. try harder...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.