mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-11-05 17:46:21 +00:00
Invalidate wired element when cable is added/removed
Otherwise we end up caching the old value of getWiredElement, which might be absent if there is no cable! Fixes #1759
This commit is contained in:
parent
c9caffb10f
commit
cbafbca86b
@ -94,10 +94,11 @@ public class CableBlockEntity extends BlockEntity {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public void setBlockState(BlockState state) {
|
public void setBlockState(BlockState state) {
|
||||||
var direction = getModemDirection();
|
var direction = getModemDirection();
|
||||||
|
var hasCable = hasCable();
|
||||||
super.setBlockState(state);
|
super.setBlockState(state);
|
||||||
|
|
||||||
// We invalidate both the modem and element if the modem's direction is different.
|
// We invalidate both the modem and element if the modem direction or cable are different.
|
||||||
if (getModemDirection() != direction && modemChanged != null) modemChanged.run();
|
if (modemChanged != null && (hasCable() != hasCable || getModemDirection() != direction)) modemChanged.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
Loading…
Reference in New Issue
Block a user