I just posted a new mod that you guys may or may not be interested in, it is a WIP so check it out if you want to, and please provide some feedback. ^^
---
Original Post
---
I am working on some bugs in my mod, Vanilla 1.6.4 at the moment. What in the Code of lets say, the Piston or any other block, tells the Redstone that it can or can not connect to that block?
That's what I was thinking but, using CTRL + F to find things, I can't find "canConnectRedstone" in any of the main 3 Piston Java documents, or the main 2 Java docs for the Repeater, and Redstone Wire. :/
In BlockRedstoneWire.Java I found this,
/**
* Returns true if redstone wire can connect to the specified block. Params: World, X, Y, Z, side (not a normal
* notch-side, this can be 0, 1, 2, 3 or -1)
*/
public static boolean isPowerProviderOrWire(IBlockAccess par0IBlockAccess, int par1, int par2, int par3, int par4)
{
int var5 = par0IBlockAccess.getBlockId(par1, par2, par3);
if (var5 == Block.redstoneWire.blockID)
{
return true;
}
else if (var5 == 0)
{
return false;
}
else if (!Block.redstoneRepeaterIdle.func_94487_f(var5))
{
return Block.blocksList[var5].canProvidePower() && par4 != -1;
}
else
{
int var6 = par0IBlockAccess.getBlockMetadata(par1, par2, par3);
return par4 == (var6 & 3) || par4 == Direction.rotateOpposite[var6 & 3];
}
}
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
Line 2095 in the "net.minecraft.block.Block" Class. Should be the correct method. If not, please do tell.
Looking at the obfuscated Java file Block.Java (1.6.4), mine does not go past line 1393, and again, trying to use CTRL + F failed to pull up anything, even doing File Search pulled nothing up for me.
Looking at the obfuscated Java file Block.Java (1.6.4), mine does not go past line 1393, and again, trying to use CTRL + F failed to pull up anything, even doing File Search pulled nothing up for me.
Maybe the name is something different in 1.6.4?
May you post the whole code so I can compare it to other code that's in the files?
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
{
return Block.blocksList[blockID].canProvidePower() && side != -1;
}
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
{
return Block.blocksList[blockID].canProvidePower() && side != -1;
}
It doesn't seem to change the functionality of the redstone connecting to my block at all.
I assume you have to paste it into the Block file and then implement it into your mod file, right?
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
{
return Block.blocksList[blockID].canProvidePower() && side != -1;
}
That method is added to the Block class by Forge. The OP is not using Forge (read their signature), so won't work.
It doesn't seem to change the functionality of the redstone connecting to my block at all.
I assume you have to paste it into the Block file and then implement it into your mod file, right?
Read above for explanation why it doesn't work. And no, you wouldn't paste it in Block, as it wouldn't work regardless, Forge calls it to change the direction of redstone, without Forge, method is never called, redstone never changes direction.
Rollback Post to RevisionRollBack
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
That method is added to the Block class by Forge. The OP is not using Forge (read their signature), so won't work.
Read above for explanation why it doesn't work. And no, you wouldn't paste it in Block, as it wouldn't work regardless, Forge calls it to change the direction of redstone, without Forge, method is never called, redstone never changes direction.
That method is added to the Block class by Forge. The OP is not using Forge (read their signature), so won't work.
Read above for explanation why it doesn't work. And no, you wouldn't paste it in Block, as it wouldn't work regardless, Forge calls it to change the direction of redstone, without Forge, method is never called, redstone never changes direction.
hopefully the following is not altered by Forge code, but I guess it is not (even though it should *cough*).
Anyhow, I just fiddled around with the Redstone propagation and stumbled across one method that calculates current strength.
In the class "BlockRedstoneWire", the "updateAndPropagateCurrentStrength(...)" method which then calls "calculateCurrentChanges(...)".
....
..and that's basically it. If you have further questions, feel free to ask, maybe I can answer them. ^^
Happy modding!
#Edit: Just noticed I ran exactly around your question. Well, basically, as we can now see, redstone uses no Metadata for its connection, as it is used by the strength already. So I'd guess the facing is retrieved directly during rendering of the block. [Otherwise I bet Mojang applied on of their magic tricks, where things simply appear the way they are supposed to be, due to some extremely unreadable code.. But, it's just my opinion.]
O.Oll
Well... That's more explanation that I had expected to get from anyone really... XD
But I'm not sure exactly how I am supposed to stop the Redstone wire from connecting to my block... Well...
Maybe I should be more specific... I am trying to make it so that BENT Redstone (wire that's connected to something else and trying to connect to my block) will not connect to my block. It's not even able to send power to the block, and I don't remember it happening in earlier test, so I think I added it in sometime ago accidentally.
I see. Well, I am certain that there are blocks (repeaters, for example) who do the reverse, but I am unsure how to get what you want..
It seems to be more a graphical failure than a functional one anyway.. Do you have backups that we can compare to the current version?
Checking back all the way to my second backup (currently on Backup 19, woot), the issue still persist, I guess I just never noticed it.
But my block is somewhat using the Repeater code, but I know the sides of the repeater do not have this function.
EDIT: Although my block is able to take input to all sides, maybe that's the issue?
Okay, have fun. Let me know if there's still no solution.
While looking at some of my changes, I noticed there is another issue with my mod, maybe you'd know how to fix, but it doesn't allow anything to be placed ON the sides of the bock when it's set to true, and doesn't actually let the block output power when false, but the items can be placed on the sides.
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return true;
}
Do you know a way around this? I've tried rewriting it, but it's coded into the Block.java too
Sure. Well, the method should in your case return true, as you want to output power, right?
The reason this happens is the way Minecraft treats your block. If you make the method return true, Minecraft deals with your block as if it is part of the redstone mechanism - like a wire, repeater, or whatever. So, of course, placing a lever on the side of a wire is not possible, so Minecraft will refuse to do so with your block as well. If it is urgent to have the ability to place levers/ buttons on the side of your block, there'll be need to rewrite (or rather override) several pieces of code/ redstone logic.. I wouldn't take the effort, to be honest.. But if it is important, we may take a look at what we can do about that. ^^
Greetings!
Having buttons and leavers being capable of being placed on the sides would be a rather nice feature for this block.... For some reason the Redstone Torches are still able to be on the sides regardless...
So an override would probably be a good idea, though I don't yet know how to do an override... Unless I've done in unintentionally.
Could you show me an override example?
Okay, that thing with the torches buffs me. x'D
I'll check where the points are and tell you later.. ^^
#Edit: Btw, which class does your block extends, anyway?
#Edit²: What does your "isOpaqueCube()" method return?
Before posting this reply, it was extending BlockDirectional, but I was just using that for the getOrientation, so I put it in my code and it now extends Block.java, but appears to function exactly like before.
public boolean isOpaqueCube()
{
return true;
}
Also, I found that the bottom of the block (Always opposite to the output), is weirdly taking in power, I think like the Repeater would. So the issue could be that I took the Repeater code, made it so that it can go in any orientation, and now the 0 and 1 sides are still input output, though I specifically added code to make the output not take in power, that was an issue before.
Would you mind posting the method(s) you modified to obtain the input/ output?
And concerning the extension, you maybe want to extend BlockRedstoneLogic? It contains the base for a repeater, and, if you change some parts, may even only allow output. Otherwise you maybe like to take a look at GregTech's code (if there's a source somewhere flying around), he has (as far as I know) some machines working with Redstone..
Greetings!
My block files just takes some code from the Repeater and RedstoneLogic, they don't extend from either Repeater or RedstoneLogic
So the main block is BlockDirectionalOutput, which extends BlockDirectionalLogic, and then BlockDirectional Logic extends Block
Output works, it's coded to only output to the top(Side with the dot), which is how I want it to.
Did you override the "getInputStrength(...)" method from BlockRedstoneLogic? I'd guess that if it simply always returns 0, there may be no further input to propagate.
And some readability- improvements here..: ^^
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
int var6 = getOrientation(var5);
The mod files are independent of the BlockRedstoneRepeater or BlockRedstoneLogic, they just borrow some code.
The modification you made to my isProvidingWeakPower doesn't seem to work.
If you leave out the IF it tells you it needs a variable, and then when you add it this happens,
getInput is set to return 15 because that's the input level. Setting it to 0 means no input... According to my test.
#EDIT: Also, I like how I have isProvidingWeakPower set up for the coding, it's good for quickly seeing the orientations, so it's fine with me as is right now.
I just posted a new mod that you guys may or may not be interested in, it is a WIP so check it out if you want to, and please provide some feedback. ^^
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2300833-vertical-halfslabs-supports-vanilla-1-6-4
---
Original Post
---
I am working on some bugs in my mod, Vanilla 1.6.4 at the moment. What in the Code of lets say, the Piston or any other block, tells the Redstone that it can or can not connect to that block?
Any help is appreciated.
~Sid
That's what I was thinking but, using CTRL + F to find things, I can't find "canConnectRedstone" in any of the main 3 Piston Java documents, or the main 2 Java docs for the Repeater, and Redstone Wire. :/
In BlockRedstoneWire.Java I found this,
But that seems to be about it for now.
Using Vanilla 1.6.4 & MCP811 w/ Eclipse
Line 2095 in the "net.minecraft.block.Block" Class. Should be the correct method. If not, please do tell.
Looking at the obfuscated Java file Block.Java (1.6.4), mine does not go past line 1393, and again, trying to use CTRL + F failed to pull up anything, even doing File Search pulled nothing up for me.
http://i.gyazo.com/8c35cf4c3e2ddec869cdbf09b3dcb8db.png
Maybe the name is something different in 1.6.4?
May you post the whole code so I can compare it to other code that's in the files?
It doesn't seem to change the functionality of the redstone connecting to my block at all.
I assume you have to paste it into the Block file and then implement it into your mod file, right?
That method is added to the Block class by Forge. The OP is not using Forge (read their signature), so won't work.
Read above for explanation why it doesn't work. And no, you wouldn't paste it in Block, as it wouldn't work regardless, Forge calls it to change the direction of redstone, without Forge, method is never called, redstone never changes direction.
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
My Github page.
The entire Minecraft shader development community now has its own Discord server! Feel free to join and chat with all the developers!
Ah, I guess they did not see when I said what I was using to mod with. :/
*Face-plam* I'm just derping a lot aren't I?
Or if there's a marker made by forge, like the old days.
However we're getting off-topic by talking about this.
/Off-topic?
O.Oll
Well... That's more explanation that I had expected to get from anyone really... XD
But I'm not sure exactly how I am supposed to stop the Redstone wire from connecting to my block... Well...
Maybe I should be more specific... I am trying to make it so that BENT Redstone (wire that's connected to something else and trying to connect to my block) will not connect to my block. It's not even able to send power to the block, and I don't remember it happening in earlier test, so I think I added it in sometime ago accidentally.
Checking back all the way to my second backup (currently on Backup 19, woot), the issue still persist, I guess I just never noticed it.
But my block is somewhat using the Repeater code, but I know the sides of the repeater do not have this function.
EDIT: Although my block is able to take input to all sides, maybe that's the issue?
Hmm, well I had to rewrite a lot of the input/output codes, I will test some things to see which one is causing it to connect.
While looking at some of my changes, I noticed there is another issue with my mod, maybe you'd know how to fix, but it doesn't allow anything to be placed ON the sides of the bock when it's set to true, and doesn't actually let the block output power when false, but the items can be placed on the sides.
Do you know a way around this? I've tried rewriting it, but it's coded into the Block.java too
Having buttons and leavers being capable of being placed on the sides would be a rather nice feature for this block.... For some reason the Redstone Torches are still able to be on the sides regardless...
So an override would probably be a good idea, though I don't yet know how to do an override... Unless I've done in unintentionally.
Could you show me an override example?
Before posting this reply, it was extending BlockDirectional, but I was just using that for the getOrientation, so I put it in my code and it now extends Block.java, but appears to function exactly like before.
Also, I found that the bottom of the block (Always opposite to the output), is weirdly taking in power, I think like the Repeater would. So the issue could be that I took the Repeater code, made it so that it can go in any orientation, and now the 0 and 1 sides are still input output, though I specifically added code to make the output not take in power, that was an issue before.
Or it's inside a base class underneath the big FORGE START comment.
Author of the Clarity, Serenity, Sapphire & Halcyon shader packs for Minecraft: Java Edition.
My Github page.
The entire Minecraft shader development community now has its own Discord server! Feel free to join and chat with all the developers!
My block files just takes some code from the Repeater and RedstoneLogic, they don't extend from either Repeater or RedstoneLogic
So the main block is BlockDirectionalOutput, which extends BlockDirectionalLogic, and then BlockDirectional Logic extends Block
Output works, it's coded to only output to the top(Side with the dot), which is how I want it to.
And, I believe this is all for input and output so far. http://pastebin.com/hy18JArD
The mod files are independent of the BlockRedstoneRepeater or BlockRedstoneLogic, they just borrow some code.
The modification you made to my isProvidingWeakPower doesn't seem to work.
If you leave out the IF it tells you it needs a variable, and then when you add it this happens,
getInput is set to return 15 because that's the input level. Setting it to 0 means no input... According to my test.
#EDIT: Also, I like how I have isProvidingWeakPower set up for the coding, it's good for quickly seeing the orientations, so it's fine with me as is right now.
Alright man, have a good night.
(I guess... xD)