|
18 | 18 | import net.minecraft.world.item.enchantment.EnchantmentHelper; |
19 | 19 | import net.minecraft.world.level.Level; |
20 | 20 | import net.minecraft.world.level.entity.EntityTypeTest; |
| 21 | +import net.minecraft.world.level.storage.ValueInput; |
| 22 | +import net.minecraft.world.level.storage.ValueOutput; |
21 | 23 | import net.minecraft.world.phys.AABB; |
22 | 24 | import net.minecraft.world.phys.Vec3; |
23 | 25 | import org.spongepowered.asm.mixin.Mixin; |
@@ -138,7 +140,7 @@ public void playerTouch(Player rawPlayer, CallbackInfo ci) { |
138 | 140 | cir.setReturnValue(clumps$currentEntry |
139 | 141 | .map(foundItem -> { |
140 | 142 | ItemStack itemstack = foundItem.itemStack(); |
141 | | - int xpToRepair = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.serverLevel(), itemstack, (int) (actualValue * Services.PLATFORM.getRepairRatio(itemstack))); |
| 143 | + int xpToRepair = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.level(), itemstack, (int) (actualValue * Services.PLATFORM.getRepairRatio(itemstack))); |
142 | 144 | int toRepair = Math.min(xpToRepair, itemstack.getDamageValue()); |
143 | 145 | itemstack.setDamageValue(itemstack.getDamageValue() - toRepair); |
144 | 146 | if(toRepair > 0) { |
@@ -191,29 +193,26 @@ private static void tryMergeToExisting(ServerLevel serverLevel, Vec3 vec3, int v |
191 | 193 |
|
192 | 194 |
|
193 | 195 | @Inject(method = "addAdditionalSaveData", at = @At("TAIL")) |
194 | | - public void addAdditionalSaveData(CompoundTag compoundTag, CallbackInfo ci) { |
| 196 | + public void addAdditionalSaveData(ValueOutput valueOutput, CallbackInfo ci) { |
195 | 197 |
|
196 | 198 | if(clumps$clumpedMap != null) { |
197 | 199 | CompoundTag map = new CompoundTag(); |
198 | 200 | clumps$getClumpedMap().forEach((value, count) -> map.putInt(String.valueOf(value), count)); |
199 | | - compoundTag.put("clumpedMap", map); |
| 201 | + valueOutput.store("clumpedMap", CompoundTag.CODEC, map); |
200 | 202 | } |
201 | 203 | } |
202 | 204 |
|
203 | 205 | @Inject(method = "readAdditionalSaveData", at = @At("TAIL")) |
204 | | - public void readAdditionalSaveData(CompoundTag compoundTag, CallbackInfo ci) { |
| 206 | + public void readAdditionalSaveData(ValueInput valueInput, CallbackInfo ci) { |
205 | 207 |
|
206 | 208 | Map<Integer, Integer> map = new HashMap<>(); |
207 | | - if(compoundTag.contains("clumpedMap")) { |
208 | | - CompoundTag clumpedMap = compoundTag.getCompoundOrEmpty("clumpedMap"); |
| 209 | + valueInput.read("clumpedMap", CompoundTag.CODEC).ifPresentOrElse(clumpedMap -> { |
209 | 210 | for(String s : clumpedMap.keySet()) { |
210 | 211 | clumpedMap.getInt(s).ifPresent(value -> { |
211 | 212 | map.put(Integer.parseInt(s), value); |
212 | 213 | }); |
213 | 214 | } |
214 | | - } else { |
215 | | - map.put(getValue(), count); |
216 | | - } |
| 215 | + }, () -> map.put(getValue(), count)); |
217 | 216 |
|
218 | 217 | clumps$setClumpedMap(map); |
219 | 218 | } |
|
0 commit comments