Skip to content

Commit

Permalink
feat(common): store item rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
flowerinsnowdh committed Dec 10, 2024
1 parent 85fa007 commit 7494bf3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins() {
}

group = 'cn.flowerinsnow.greatscrollabletooltips'
version = '1.1.0'
version = '1.2.0'

repositories() {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion common/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ org.gradle.jvmargs=-Dfile.encoding=UTF-8

# Dependencies
night_config_version=3.8.1
junit_version=5.11.0
junit_version=5.11.3
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public class ScrollSession<I> {
*/
private int vertical;
/**
* <p>本 tick 是否渲染中</p>
* <p>当前正在渲染的物品堆</p>
*/
private boolean rendering;
private I itemStackRendering;

/**
* <p>最后一次渲染的物品</p>
* <p>上一次渲染的物品堆</p>
* <p>记录以方便判断是否要回正</p>
*/
private I lastItemStackRendered;
Expand Down Expand Up @@ -50,12 +50,16 @@ public void addVertical(int value) {
this.vertical += value;
}

public boolean isRendering() {
return this.rendering;
public boolean isItemStackRendering() {
return this.itemStackRendering != null;
}

public void setRendering(boolean rendering) {
this.rendering = rendering;
public I getItemStackRendering() {
return this.itemStackRendering;
}

public void setItemStackRendering(I itemStackRendering) {
this.itemStackRendering = itemStackRendering;
}

public I getLastItemStackRendered() {
Expand All @@ -79,15 +83,15 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ScrollSession<?> that = (ScrollSession<?>) o;
return this.horizontal == that.horizontal && this.vertical == that.vertical && this.rendering == that.rendering && Objects.equals(this.lastItemStackRendered, that.lastItemStackRendered);
return this.horizontal == that.horizontal && this.vertical == that.vertical && Objects.equals(this.itemStackRendering, that.itemStackRendering) && Objects.equals(this.lastItemStackRendered, that.lastItemStackRendered);
}

@Override
public int hashCode() {
int result = 17;
result = 31 * result + this.horizontal;
result = 31 * result + this.vertical;
result = 31 * result + (this.rendering ? 1231 : 1237);
result = 31 * result + (this.itemStackRendering != null ? this.itemStackRendering.hashCode() : 0);
result = 31 * result + (this.lastItemStackRendered != null ? this.lastItemStackRendered.hashCode() : 0);
return result;
}
Expand All @@ -97,7 +101,7 @@ public String toString() {
return "ScrollSession{" +
"horizontal=" + this.horizontal +
", vertical=" + this.vertical +
", rendering=" + this.rendering +
", itemStackRendering=" + this.itemStackRendering +
", lastItemStackRendered=" + this.lastItemStackRendered +
'}';
}
Expand Down

0 comments on commit 7494bf3

Please sign in to comment.