![[π¦] Logic Gates (Fabric)](https://media.forgecdn.net/avatars/thumbnails/514/218/256/256/637834701534097297.png)
Additional wires
Mindtester opened this issue Β· 15 comments
I finally managed to implement and (somewhat) get the wire blocks to work. The two main issues with those wires are them not accepting inputs from levers and them not supporting being placed next to one another. That second one has things to do with how they handle block updates. For now I think I will publish the those blocks in a beta update, and then once I resolve those two issues, I will publish them as a release.
Thank you!
I prefer first variant. As the second one is the same as OR-gate. For the cross wire 1-to-3 is preferable.
Ideally it should be configurable. For example, there could be some kind of base and using torches and pieces of redstone representing inputs and outputs around this base in crafting grid like you did it with straight and turn wires will allow to create any possible type of wire. Or it could be a single block where the type of each side could be switched between input/output/null with RClick.
But this also could replace OR-gates in some configurations. So it's better to have only 1 input (base with one input) and only outputs should be crafted/configured.
Hello, sure thing. I just need to know how exactly they would work in terms of inputs and outputs. What I mean is, where would their inputs and outputs be placed? Would they have one input while all other sides are outputs, or the opposite, or maybe some other behavior?
For example, for the T-cross, which one would it be?:
βββββββββββββββ βββββββββββββββ
β β β β
β β β β
β β β β
β β β βββ°ββ βΊ ββ₯ or β β βΊ βββ°ββ β ββ₯
β β β β β β
β β² β β βΌ β
β β β β β β
ββββββββΈβββββββ ββββββββΈβββββββ
Have tested 1.3.1 version. It seems new wires supports being placed next to each other now. But lever still doesn't work. Is it normal for this release? Or I just did something wrong? And new wires doesn't glow.
BTW, old wires accepts signal from lever well. Also neither old wires nor new ones work with powered block. I mean old ones could power block but cannot be powered from it, new ones can't do both.
Another issue is new wires have longer delay.
And finally new wires required to be glued to stay with moving contraption from Create. Old wires, gates and latches do not.
Hello. I am aware of the issues you mentioned. I will try and explain some of them.
The main thing causing most of those issues is that the new wires are not like the rest of the blocks in the mod. Logic gates and old wires are modified versions of repeaters. So they are basically blocks with one/two input(s) and one output, just like a redstone repeater. The problem took place when I wanted to write the new wires. Because the new wires have multiple inputs and outputs, I coudn't just "fork" (aka extend) a redstone repeater and change up it's code a bit. I had no other choice but to rewrite the behaviours of those blocks from scratch. This also means that ticking, input/output handling, and pretty much every other behavior had to be rewritten just for that custom type of block for the new wires. This of course resulted in some issues and inconsistencies.
As for the textures of the new wires. I probably should have made it so they glow, and I probably will. But here's why I didn't. Texturing the logic gates was simple, as they only had two possible states (excluding FACING), which where "powered" and "not powered". Simple. This meant that I only had to write textures and the blockstates json file to handle those two states. However, with the new type of wires.. they have multiple inputs and outputs. They can be powered and not powered on all 4 sides (E/W/N/S), plus you also have to handle FACING. So 2*2*2*2*4 is already 64 maximum possible variations (the new wires have less, around 32 i think), so I didn't even bother handling all of them.
As for the lever issue. I tried to resolve it, and I will try again. The thing is, since the new wires are a different type of blocks (and not extensions of repeaters), their input handling had to be rewritten (because you have to do that for every new type of block you create). And so, for some reason, everything worked fine, except levers.. I even tried copy/pasting the code repeaters use to fetch input, but that didn't seem to do the trick either, and so I just gave up trying. Perhaps the solution is in the lever's code? Perhaps levers are hard-coded to give inputs to certain blocks? I will have to see.
Also I tested out that ticking issue you mentioned about new wires having longer delay, and... no they don't (edit: you were right, they do). Unless I am missing something? Because I placed the new and old wires side by side, placed lamps at the end of the line of those wires, powered both lines using redstone dust and a lever. The lamps turned on at the same time.
As for the Create mod. I honestly don't know how that mod handles gluing blocks. My assumption is that the mod doesn't require you to glue redstone gate blocks, but remember, like I said earlier, because redstone gate blocks have one input and output, I had to create a custom type of block just for the new wires. Perhaps that is why Create doesn't recognise them as like a redstone component or something? I don't know honestly. If that is the issue, then I don't think there is anything I can do about that. I however will check out Create and try and see if I can figure something out.
Sorry for the long reply, and thanks for the comment. I will try and do something about the issues. I still haven't figured out how to get ticking going for 1.19. Because of course 1.19 had to be 1.19, and Mojang/Fabric or whoever had to rewrite a bunch of stuff in the game's code, making the modding experience way more difficult, and porting mods to newer versions an... annoying process. Now for whatever reason, while the game will tick redstone gates, for whatever reason it refuses to tick this new type of block for the new wires, even tho the new block type has the code that handles ticking (which works perfectly fine on 1.18).
Edit: grammar fixes and word fixes.
Quick note. I finally managed to resolve the lever issue and the ticking issue in 1.19.
For the lever issue, in addition Minecraft's way of checking for redstone input, I also made the wires check for any powered lever blocks.
As for the ticking issue, of course they had to suddenly make their own class for Random
, because "why not"... So it's no longer java.util.Random
, it's net.minecraft.util.math.random.Random
. Now that I know that, I was able to make ticking work again.
I will now publish the patches as v1.3.2
and work on the rest of the issues.
Edit:
Regarding the ticking issue. It appears you are right about it. I just tested it again, and I managed to reproduce the issue. I will try and resolve it in the next update.
I guess latches are implemented on comparator code so wires (repeaters) and latches/gates (comaparators) are working with Create which work with vanilla. But could wires be based on vanilla RS wire? Every input could be an output. As long as Create recognize your wires as vanilla there should be no problems in default behavior. Otherwise block have to be glued to directly assign it to contraption.
TBH, hardcoding levers was a not good idea because there are also buttons :) There should be a way to detect indirect signal when redstone powers adjacent block. This could solve all issues with powered blocks and probably levers/buttons. Only notes I found are kinda old like here or here.
Also in newest (1.3.2.1) version after you power a block with new wires you probably need to update something. The way to reproduce it: lever-wire-block-RS wire on top of the block. When you pull lever RS-wire on top of the block stays off. You need to brake and replace it. Same happens when you pull lever off. Especially with T-wire and two blocks when you brake RS-wire on one block RS-wire on other block lits on immidiatelly.
I guess latches are implemented on comparator code so wires (repeaters) and latches/gates (comaparators) are working with Create which work with vanilla.
Both logic gate blocks (AbstractLogicGateBlock
) and "side" logic gate blocks (AbstractLogicSideGateBlock
) that take input from their sides extend a Minecraft's class called AbstractRedstoneGateBlock
. The Minecraft's RepeaterBlock
and ComparatorBlock
also extend this class. The name of the class should be self explanatory. It is a type of block for redstone gates. Redstone gates can take input from any direction, but output in only one direction. This output thing was my issue.
Create probably checks if a block is an AbstractRedstoneGateBlock
, and if it is, it doesn't require it to be glued. I am not entirely sure.
TBH, hardcoding levers was a not good idea because there are also buttons :)
Tbh, I agree in a way. I did however check the lever code to see how it handles retrieving it's redstone power, and I found nothing out of the ordinary:
public int getStrongRedstonePower(BlockState state, BlockView world, BlockPos pos, Direction direction)
{
if ((state.get(POWERED)) && getDirection(state) == direction)
return 15;
return 0;
}
As you can see, the lever checks if it is powered and facing the right way towards the block, and if it is, it will return a power of 15
, and 0
otherwise. What I found weird however, is that my code already uses world.getStrongRedstonePower
, and it still returns 0. I tried rotating the lever in all directions as well to make sure the direction wasn't an issue. Didn't seem to work. So I just hard-coded checking for levers. AbstractRedstoneGateBlock
s also use world.getStrongRedstonePower
to get redstone power, and they work perfectly fine, so I don't know what the issue is.
Since you mentioned buttons, I just decided to check for any type of block that can be powered and that has the WallMountedBlock.FACE
property that faces into the ground. This successfully made the new wires recognise both levers and buttons.
Also in newest (1.3.2.1) version after you power a block with new wires you probably need to update something.
You mean this?:
If so, then yeah, thanks for pointing that out. I will need to patch the bug with the proper blocks not updating when the wire outputs are pointing into solid blocks.
Also, just a few more things
I am currently working on texturing the new wires and making them actually show glow when powered, just like the other blocks do.
In terms of Create, I still don't know what to do. I made the new wires extend HorizontalFacingBlock
now instead of Block
. Hopefully that does something? I took a look at RedstoneWireBlock
, and it's... not feasible to extend it, as their behavior is like... it's better to just write a new block. You mentioned how perhaps I cound extend redstone wires, and override the behaviour since they can accept inputs and outputs from all sides. There are a few issues with that. First of all, as you mentioned, their inputs and outputs are literally on all sides, they behave a lot differently than redstone gate blocks in terms of how they handle input/output (which isn't the kind of behavior I need), and they have properties I don't need as well.
Also, when you "extend" a block, your blocks inherits all of the behavior and properties from that extended block. The code also becomes a bit of a mess, as the class not only has it's own methods and fields and stuff, but the ones it inherited as well. Not too much of an issue tho.
Redstone wires have properties that keep track of wire connections east
west
north
south
, as well as the power
property. I don't need any of those. I only need powered
and facing
, none of which are part of redstone wires, so I might as well re-write the block behavior myself without extending a redstone wire.
By the way, the difference between power
and powered
is that power
ranges from 0
to 15
, while powered
can only be set to true
and false
. In other words, power
is an IntegerProperty
while powered
is a BooleanProperty
.
Sorry for yet another large block of text. I will now get to handling textures for like like 32 possible states for the cross wire block. I will try and patch the bug you mentioned as well while at it. I also fixed that ticking issue you mentioned before. Once finished, I will publish all of the patches.
With regards to Create my point is to make all your wires/gates/latches unified some time in the future. Will it be vanilla-style or via new blocks doesn't really matter.
The idea in provided links was that sometimes you need to invert directions in checks for your own blocks when checking for nearby powered blocks. As direction for your block's side where you perform check is opposite for the block that send power to your block. Not sure if it's your case.
Instead of 32 textures have you considered a layered texture?
Instead of 32 textures have you considered a layered texture?
I wanted to mention, I am aware of those, and no I am not actually going to make 32 separate textures. That would be dumb. What I meant is the blockstates/[block_namespace].json
file. I have to define what model the block will use for each possible state. Maybe I could reduce 32 down to a lower number by using multipart
instead of variants
more info here.
The end result was 8 models extending one base model. Each of the 8 models has a separate texture defined. So that's 8 models, and since blockstates.json can rotate models, that makes it 8*4=32.
Of course, it can be a bit messy, but this ended up being the end result:
{
"variants":
{
"swapped_direction=false,facing=east,powered_east=false,powered_west=false,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_00", "y": 270 },
"swapped_direction=false,facing=west,powered_east=false,powered_west=false,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_00", "y": 90 },
"swapped_direction=false,facing=north,powered_east=false,powered_west=false,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_00", "y": 180 },
"swapped_direction=false,facing=south,powered_east=false,powered_west=false,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_00", "y": 0 },
"swapped_direction=false,facing=east,powered_east=false,powered_west=false,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_01", "y": 270 },
"swapped_direction=false,facing=west,powered_east=false,powered_west=false,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_01", "y": 90 },
"swapped_direction=false,facing=north,powered_east=false,powered_west=false,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_01", "y": 180 },
"swapped_direction=false,facing=south,powered_east=false,powered_west=false,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_01", "y": 0 },
"swapped_direction=false,facing=east,powered_east=true,powered_west=false,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_10", "y": 270 },
"swapped_direction=false,facing=west,powered_east=true,powered_west=false,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_10", "y": 90 },
"swapped_direction=false,facing=north,powered_east=true,powered_west=false,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_10", "y": 180 },
"swapped_direction=false,facing=south,powered_east=true,powered_west=false,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_10", "y": 0 },
"swapped_direction=false,facing=east,powered_east=true,powered_west=false,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_11", "y": 270 },
"swapped_direction=false,facing=west,powered_east=true,powered_west=false,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_11", "y": 90 },
"swapped_direction=false,facing=north,powered_east=true,powered_west=false,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_11", "y": 180 },
"swapped_direction=false,facing=south,powered_east=true,powered_west=false,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_11", "y": 0 },
"swapped_direction=true,facing=east,powered_east=false,powered_west=false,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_s_00", "y": 270 },
"swapped_direction=true,facing=west,powered_east=false,powered_west=false,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_s_00", "y": 90 },
"swapped_direction=true,facing=north,powered_east=false,powered_west=false,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_s_00", "y": 180 },
"swapped_direction=true,facing=south,powered_east=false,powered_west=false,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_s_00", "y": 0 },
"swapped_direction=true,facing=east,powered_east=false,powered_west=false,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_s_01", "y": 270 },
"swapped_direction=true,facing=west,powered_east=false,powered_west=false,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_s_01", "y": 90 },
"swapped_direction=true,facing=north,powered_east=false,powered_west=false,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_s_01", "y": 180 },
"swapped_direction=true,facing=south,powered_east=false,powered_west=false,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_s_01", "y": 0 },
"swapped_direction=true,facing=east,powered_east=false,powered_west=true,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_s_10", "y": 270 },
"swapped_direction=true,facing=west,powered_east=false,powered_west=true,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_s_10", "y": 90 },
"swapped_direction=true,facing=north,powered_east=false,powered_west=true,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_s_10", "y": 180 },
"swapped_direction=true,facing=south,powered_east=false,powered_west=true,powered_north=false": { "model": "logicgates:block/wire_cross/wire_cross_s_10", "y": 0 },
"swapped_direction=true,facing=east,powered_east=false,powered_west=true,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_s_11", "y": 270 },
"swapped_direction=true,facing=west,powered_east=false,powered_west=true,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_s_11", "y": 90 },
"swapped_direction=true,facing=north,powered_east=false,powered_west=true,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_s_11", "y": 180 },
"swapped_direction=true,facing=south,powered_east=false,powered_west=true,powered_north=true": { "model": "logicgates:block/wire_cross/wire_cross_s_11", "y": 0 }
}
}
Maybe I should consider multipart
in the future.
Almost there! :)
For 1.3.3:
When cross wire have input for both lines clicking on it to change direction makes it flicker with purple-black no texture cube.
Placing new wires to already powered RS wire requires block update for them to work.
Oh yeah, well spotted. Swapping directions puts the block in an "invalid" state that has not been covered by the blockstates.json file. The block then gets updated and put back into a valid state 1 tick later after right clicking, causing the flicker. I will resolve this and publish a patch. Thanks a lot for pointing that out.
Edit:
In case you are wondering what happens. I believe the powered_east
and powered_west
properties have something to do with this. Basically when you swap directions, the values of those two properties need to be swapped as well, because only one of those directions is allowed to be powered at a given time, while the other direction is an input. This update of those properties takes place around 2 game ticks later, causing the flicker.
Hello again. I have just patched the bug and published it in the update v1.3.4. I would like to thank you a lot for helping me out with the new wires and for suggesting them. If there is anything else you would like to say or that needs to be done, feel free to let me know, otherwise I think I should close the issue. And as always, have a great day.