Jump to content

[SOLVED]Connecting up Two Blocks(For electrisity)


ItsAMysteriousYT

Recommended Posts

Hey there, im working on an electrizity network for my mod and now im struggling with connecting the blocks so they can pass over the energy to each other. what i did is i created a TileEntity_Electric and in there a field called connected. This is the TileEntity_Electric that should receive the energy. Now im trying to set this field with an item. In the item i have a public static TileEntity_Electric that i set like this in onItemRightClick (Called on both sites so i don't need packetHandling):

 

 

@Override

public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {

BlockPos pos = Minecraft.getMinecraft().objectMouseOver.getBlockPos();

if(world.getTileEntity(pos) instanceof TileEntity_Electric){

TileEntity_Electric toConnectTile = (TileEntity_Electric) world.getTileEntity(pos);

if(lastTile!=null&&lastTile!=toConnectTile){

lastTile.connectTo(toConnectTile);

lastTile=toConnectTile;

}

else{

player.addChatMessage(new ChatComponentText("Now in "+EnumChatFormatting.GREEN+"Connection Mode"+EnumChatFormatting.RESET+"To stop connecting, hold SHIFT+RIGHTCLICK! "));

lastTile = toConnectTile;

}

 

}else

{

if(world.getBlockState(pos).getBlock() instanceof BlockAir){

player.addChatMessage(new ChatComponentText("Stopped "+EnumChatFormatting.RED+"Connection Mode"));

lastTile=null;

}

 

}

return stack;

}

 

 

 

I have a GameOverlay in which i can see if a TileEntity_Electric is connected and the tileentity that it is connected with. But somehow - these connected tiles are sometimes tileentities that are have been in the world earlier and sometimes the block that i clicked the first time. What am i doing wrong? Do i have to use another method or put the field somewhere else - please help :(

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.