Skip to content

Commit a894ae7

Browse files
committed
✨ Updated to Minecraft 1.21.6
1 parent 78093b5 commit a894ae7

File tree

5 files changed

+32
-66
lines changed

5 files changed

+32
-66
lines changed

common/src/main/java/com/mrcrayfish/goblintraders/entity/AbstractGoblinEntity.java

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.mrcrayfish.goblintraders.trades.GoblinOffers;
99
import com.mrcrayfish.goblintraders.trades.type.BaseTrade;
1010
import com.mrcrayfish.goblintraders.util.Utils;
11+
import net.minecraft.core.UUIDUtil;
1112
import net.minecraft.core.particles.ItemParticleOption;
1213
import net.minecraft.core.particles.ParticleTypes;
1314
import net.minecraft.nbt.*;
@@ -39,6 +40,8 @@
3940
import net.minecraft.world.item.trading.MerchantOffers;
4041
import net.minecraft.world.level.Level;
4142
import net.minecraft.world.level.portal.TeleportTransition;
43+
import net.minecraft.world.level.storage.ValueInput;
44+
import net.minecraft.world.level.storage.ValueOutput;
4245
import net.minecraft.world.phys.Vec3;
4346
import org.jetbrains.annotations.Nullable;
4447

@@ -330,7 +333,7 @@ protected InteractionResult mobInteract(Player player, InteractionHand hand)
330333
if(result.consumesAction())
331334
{
332335
// Remove the wandering restriction once named
333-
this.clearRestriction();
336+
this.clearHome();
334337
}
335338
return result;
336339
}
@@ -410,59 +413,28 @@ public void setDespawnDelay(int despawnDelay)
410413
}
411414

412415
@Override
413-
public void readAdditionalSaveData(CompoundTag compound)
416+
public void readAdditionalSaveData(ValueInput input)
414417
{
415-
super.readAdditionalSaveData(compound);
416-
if(compound.contains("Offers"))
417-
{
418-
this.offers = new GoblinOffers(compound.getCompoundOrEmpty("Offers"));
419-
}
420-
if(compound.contains("DespawnDelay"))
421-
{
422-
this.despawnDelay = compound.getIntOr("DespawnDelay", 0);
423-
}
424-
if(compound.contains("RestockDelay"))
425-
{
426-
this.restockDelay = compound.getIntOr("RestockDelay", 0);
427-
}
428-
if(compound.contains("TradedCustomers"))
429-
{
418+
super.readAdditionalSaveData(input);
419+
input.read("Offers", GoblinOffers.CODEC).ifPresent(offers -> this.offers = new GoblinOffers(offers));
420+
input.getInt("DespawnDelay").ifPresent(delay -> this.despawnDelay = delay);
421+
input.getInt("RestockDelay").ifPresent(delay -> this.restockDelay = delay);
422+
input.list("TradedCustomers", UUIDUtil.CODEC).ifPresent(uuids -> {
430423
this.tradedCustomers.clear();
431-
ListTag list = compound.getListOrEmpty("TradedCustomers");
432-
list.forEach(tag -> {
433-
if(tag instanceof StringTag(String value)) {
434-
UUID id = Utils.parseUuid(value);
435-
if(id != null) {
436-
this.tradedCustomers.add(id);
437-
}
438-
}
439-
});
440-
}
424+
uuids.forEach(this.tradedCustomers::add);
425+
});
441426
}
442427

443428
@Override
444-
public void addAdditionalSaveData(CompoundTag compound)
429+
public void addAdditionalSaveData(ValueOutput output)
445430
{
446-
super.addAdditionalSaveData(compound);
431+
super.addAdditionalSaveData(output);
447432
MerchantOffers offers = this.getOffers();
448-
if(!offers.isEmpty())
449-
{
450-
MerchantOffers.CODEC.encodeStart(NbtOps.INSTANCE, offers).result()
451-
.ifPresent(tag -> {
452-
compound.put("Offers", tag);
453-
});
454-
}
455-
compound.putInt("DespawnDelay", this.despawnDelay);
456-
compound.putInt("RestockDelay", this.restockDelay);
457-
458-
if(!this.tradedCustomers.isEmpty())
459-
{
460-
ListTag list = new ListTag();
461-
this.tradedCustomers.forEach(id -> {
462-
list.add(StringTag.valueOf(id.toString()));
463-
});
464-
compound.put("TradedCustomers", list);
465-
}
433+
output.store("Offers", GoblinOffers.CODEC, offers);
434+
output.putInt("DespawnDelay", this.despawnDelay);
435+
output.putInt("RestockDelay", this.restockDelay);
436+
ValueOutput.TypedOutputList<UUID> uuids = output.list("TradedCustomers", UUIDUtil.CODEC);
437+
this.tradedCustomers.forEach(uuids::add);
466438
}
467439

468440
@Nullable
@@ -591,7 +563,7 @@ public void die(DamageSource source)
591563
}
592564

593565
@Override
594-
protected Vec3 getLeashOffset()
566+
public Vec3 getLeashOffset()
595567
{
596568
return new Vec3(0, this.getEyeHeight() - 0.25, 0);
597569
}
@@ -601,7 +573,7 @@ public void setLeashedTo(Entity entity, boolean broadcast)
601573
{
602574
// When goblin becomes leashed, remove restriction
603575
super.setLeashedTo(entity, broadcast);
604-
this.clearRestriction();
576+
this.clearHome();
605577
}
606578

607579
@Override

common/src/main/java/com/mrcrayfish/goblintraders/spawner/GoblinTraderSpawner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private boolean spawnGoblin()
134134

135135
this.runDelay = this.data.getSpawnDelay();
136136
goblin.setDespawnDelay(this.data.getDespawnDelay());
137-
goblin.restrictTo(pos, 16);
137+
goblin.setHomeTo(pos, 16);
138138
this.setDirty();
139139
return true;
140140
}
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.mrcrayfish.goblintraders.trades;
22

3-
import net.minecraft.nbt.CompoundTag;
4-
import net.minecraft.nbt.NbtOps;
53
import net.minecraft.world.item.trading.MerchantOffers;
64

75
/**
@@ -11,12 +9,8 @@ public class GoblinOffers extends MerchantOffers
119
{
1210
public GoblinOffers() {}
1311

14-
public GoblinOffers(CompoundTag tag)
12+
public GoblinOffers(MerchantOffers offers)
1513
{
16-
CODEC.parse(NbtOps.INSTANCE, tag).result().ifPresent(offers -> {
17-
offers.forEach(offer -> {
18-
this.add(new GoblinMerchantOffer(offer));
19-
});
20-
});
14+
offers.forEach(offer -> this.add(new GoblinMerchantOffer(offer)));
2115
}
2216
}

gradle.properties

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ group=com.mrcrayfish
55
java_version=21
66

77
# Common
8-
minecraft_version=1.21.5
9-
neo_form_version=1.21.5-20250325.162830
8+
minecraft_version=1.21.6
9+
neo_form_version=1.21.6-20250617.151856
1010

1111
# Fabric
12-
fabric_version=0.119.9+1.21.5
13-
fabric_loader_version=0.16.13
12+
fabric_version=0.127.0+1.21.6
13+
fabric_loader_version=0.16.14
1414

1515
# NeoForge
16-
neoforge_version=21.5.38-beta
17-
neoforge_version_range=[21.5,)
16+
neoforge_version=21.6.11-beta
17+
neoforge_version_range=[21.6,)
1818
neoforge_loader_version_range=[2,)
1919

2020
# Mod options
@@ -29,7 +29,7 @@ mod_issues=https://github.com/MrCrayfish/GoblinTraders/issues
2929
mod_license=MIT
3030

3131
# Dependency options
32-
framework_version=0.11.1
32+
framework_version=0.12.1
3333
catalogue_version=1.12.1
3434

3535
# Gradle

neoforge/src/main/java/com/mrcrayfish/goblintraders/client/ClientHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/**
2828
* Author: MrCrayfish
2929
*/
30-
@EventBusSubscriber(modid = Constants.MOD_ID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD)
30+
@EventBusSubscriber(modid = Constants.MOD_ID, value = Dist.CLIENT)
3131
public class ClientHandler
3232
{
3333
@SubscribeEvent

0 commit comments

Comments
 (0)