Skip to content

Commit

Permalink
Fix writeNbt on the client side
Browse files Browse the repository at this point in the history
  • Loading branch information
Estecka committed Jul 4, 2024
1 parent d6407fb commit b279f28
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 14 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,21 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v2
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'microsoft'
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Artifacts
path: ./
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ classes/
.vscode/
bin/
.classpath
.factorypath
.project

# macos
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ processResources {
filesMatching("fabric.mod.json") {
expand "version": project.version
}

exclude "**/*.xcf"
}

tasks.withType(JavaCompile).configureEach {
Expand Down
20 changes: 17 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,24 @@ Initial release
- _Regression: Restocks cause a crash if Deplete Reroll is disabled._

# v2
## 2.0.0
## 2.0
- Made some methods and types available through an API.
- Added an entrypoint to define villager trades from outside mods
## 2.1.0
## 2.1
### 2.1.0
- Reimplemented Trade-Rebalance support in a backward-compatible way
## 2.1.1
### 2.1.1
- Fixed a crash that would occur upon restock if Depleted Reroll is disabled.
### 2.1.2 (Branched of v2.2)
- Custom serialization is no longer callable from the render thread.
## 2.2
### 2.2.0
- Updated for MC 1.20.5
- For caching, a map's `item_name` takes priority over the `custom_name` if both are present.
- Placeholder trades are no longer empty. (Cosmetic change only.)
- Added custom logic for upgrading caches from before 1.20.5
### 2.2.1
- Updated for MC 1.21
### 2.2.2
- Custom serialization is no longer callable from the render thread.
This boost performances when using Fresh Animations
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ loader_version=0.15.3
fabric_version=0.91.2+1.20.2

# Mod Properties
mod_version=2.1.1
mod_version=2.1.2
maven_group=tk.estecka.shiftingwares
archives_base_name=shifting-wares
20 changes: 20 additions & 0 deletions port.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minecraft Code Breaking Changes
### 1.19.4
Current master

### 1.20.2
#### Worked Around:
- Need to handle the experimental trade rebalance: build for 1.20.2 and check that the feature's identifier exists before executing related code.

### 1.20.5
#### No Workaround:
- `ItemStack::hasCustomName` and `FilledMapItem::getMapId` were replaced with DataComponents.
- Exploration maps now use an `item_name` instead of a `custom_name`. Map caches from older versions are not automatically upgraded by minecraft.
- `TradeOffer` now takes the price as a `TradeItem` instead of an `ItemStack`. The second price is also an `Optional`
#### Possible Workaround:
- `ItemStack::writeToNbt` and `readFromNbt` were removed or changed: Use `ItemStack::CODEC` instead.
- Trade offers no longer support selling or buying air: Use some placeholder items instead.

### 1.21.0
#### No Workaround
- `getRandom()` was moved from `LivingEntity` to its parent class `Entity`. No code change required, but needs recompilation.
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,18 @@ private boolean RestockDepletedOnly(TradeOffer offer, Operation<Boolean> hasBeen

@Inject ( method="writeCustomDataToNbt", at=@At("TAIL"))
void WriteCachedMapsToNbt(NbtCompound nbt, CallbackInfo info){
this.tradeCache.FillCacheFromTrades(villager.getOffers());
this.tradeCache.WriteMapCacheToNbt(nbt);
if (!villager.getWorld().isClient()){
this.tradeCache.FillCacheFromTrades(villager.getOffers());
this.tradeCache.WriteMapCacheToNbt(nbt);
}
}

@Inject ( method="readCustomDataFromNbt", at=@At("TAIL"))
void ReadCachedMapsFromNbt(NbtCompound nbt, CallbackInfo info){
this.tradeCache.ReadMapCacheFromNbt(nbt);
this.tradeCache.FillCacheFromTrades(villager.getOffers());
if (!villager.getWorld().isClient()){
this.tradeCache.ReadMapCacheFromNbt(nbt);
this.tradeCache.FillCacheFromTrades(villager.getOffers());
}
}

}

0 comments on commit b279f28

Please sign in to comment.