-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Speed Presets for configurable speed settings #1111
Conversation
Introduced a Speed Presets system with customizable presets for the rancher boots. Added a GUI to manage presets and integrated support for the `setmaxspeed` command, and the sign-editor to use these presets. Besides all of that, refactored item protection rendering logic to show it everywhere, where applicable, and render it in front of the item, as well as updated the texture being used.
I apologize for the changes, since I didn't know that the texture was applied elsewhere. This commit reverts all the changes to the size of the texture and the way it is rendered, to hopefully prevent any issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the item protection changes mentioned in your description. Also please separate the item protection changes and texture changes to a separate pr.
|
||
@ModifyExpressionValue(method = "drawCooldownProgress", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/ItemCooldownManager;getCooldownProgress(Lnet/minecraft/item/ItemStack;F)F")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's literally nothing changed here?
@Shadow | ||
private boolean touchIsRightClickDrag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this shadowed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question...
* | ||
* @return true if the state has been modified; false otherwise. | ||
*/ | ||
public boolean hasBeenChanged() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic has some problems, where an entry changed and then changed back to the original would still be marked as changed. In general, you need a validation method that checks if all entries are the same. I'd suggest looking at ShortcutsConfigListWidget#hasChanges
.
src/main/java/de/hysky/skyblocker/skyblock/speedPreset/SpeedPresetListWidget.java
Outdated
Show resolved
Hide resolved
src/main/java/de/hysky/skyblocker/skyblock/speedPreset/SpeedPresetListWidget.java
Outdated
Show resolved
Hide resolved
src/main/java/de/hysky/skyblocker/skyblock/speedPreset/SpeedPresets.java
Outdated
Show resolved
Hide resolved
src/main/java/de/hysky/skyblocker/skyblock/speedPreset/SpeedPresetsScreen.java
Outdated
Show resolved
Hide resolved
src/main/java/de/hysky/skyblocker/skyblock/speedPreset/SpeedPresetsScreen.java
Outdated
Show resolved
Hide resolved
src/main/java/de/hysky/skyblocker/skyblock/speedPreset/SpeedPresetsScreen.java
Outdated
Show resolved
Hide resolved
var presets = SpeedPresets.getInstance().getPresetCount(); | ||
// Accounting 1 for the title entry. | ||
var children = children().size() - 1; | ||
if (children < presets) return true; | ||
|
||
children = 0; | ||
for (var child : children()) { | ||
if (child.hasBeenModified()) return true; | ||
if (child instanceof SpeedPresetEntry entry) { | ||
children = entry.isEmpty() ? children : children + 1; | ||
} | ||
} | ||
return children != presets; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var presets = SpeedPresets.getInstance().getPresetCount(); | |
// Accounting 1 for the title entry. | |
var children = children().size() - 1; | |
if (children < presets) return true; | |
children = 0; | |
for (var child : children()) { | |
if (child.hasBeenModified()) return true; | |
if (child instanceof SpeedPresetEntry entry) { | |
children = entry.isEmpty() ? children : children + 1; | |
} | |
} | |
return children != presets; | |
return children().stream().anyMatch(AbstractEntry::hasBeenModified) || children().stream().filter(SpeedPresetEntry.class::isInstance).map(SpeedPresetEntry.class::cast).filter(entry -> !entry.isEmpty()).count() != SpeedPresets.getInstance().getPresetCount(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This results into two separate loops although it could be done it one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good api here btw.
Yeah, I shouldn't have included it in this PR in the first place, but I'll try to revert the changes and use the old texture |
…esetsScreen.java Co-authored-by: Kevin <[email protected]>
…esetListWidget.java Co-authored-by: Kevin <[email protected]>
…esets.java Co-authored-by: Kevin <[email protected]>
…esetsScreen.java Co-authored-by: Kevin <[email protected]>
…esetsScreen.java Co-authored-by: Kevin <[email protected]>
…esetListWidget.java Co-authored-by: Kevin <[email protected]>
…esets.java Co-authored-by: Kevin <[email protected]>
…esets.java Co-authored-by: Kevin <[email protected]>
…esets.java Co-authored-by: Kevin <[email protected]>
…esetListWidget.java Co-authored-by: Kevin <[email protected]>
…esets.java Co-authored-by: Kevin <[email protected]>
…esets.java Co-authored-by: Kevin <[email protected]>
Removed the `hasBeenModified` flag, and replaced it with direct comparisons of initial and current values.
Replaced LinkedHashMap with Object2IntMap for efficiency and consistency in managing speed presets. Adjusted related methods and logic to accommodate the new data structure. Updated SpeedPresetListWidget to handle changes and comparisons using the revised map implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for contributing!
Introduced a Speed Presets system with customizable presets for the rancher boots. Added a GUI to manage presets and integrated support for the
setmaxspeed
command, and the sign-editor to use these presets.Besides all of that, refactored item protection rendering logic to show it everywhere, where applicable, and render it in front of the item, as well as updated the texture being used.