Jump to content

Cables


tattyseal

Recommended Posts

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)

{

 

}

 

}

 

 

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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