Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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)

{

 

}

 

}

 

 

 

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.