mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 06:26:43 +01:00
Use the entity's accessor for the registry manager instead
This commit is contained in:
parent
ab25ab7556
commit
9789b0f738
14 changed files with 30 additions and 30 deletions
|
@ -157,7 +157,7 @@ public class ItemImpl implements Equine<ItemEntity> {
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(NbtCompound compound, WrapperLookup lookup) {
|
public void toNBT(NbtCompound compound, WrapperLookup lookup) {
|
||||||
compound.putString("owner_race", getSpecies().getId().toString());
|
compound.putString("owner_race", getSpecies().getId().toString());
|
||||||
physics.toNBT(compound);
|
physics.toNBT(compound, lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -165,7 +165,7 @@ public class ItemImpl implements Equine<ItemEntity> {
|
||||||
if (compound.contains("owner_race", NbtElement.STRING_TYPE)) {
|
if (compound.contains("owner_race", NbtElement.STRING_TYPE)) {
|
||||||
setSpecies(Race.fromName(compound.getString("owner_race"), Race.HUMAN));
|
setSpecies(Race.fromName(compound.getString("owner_race"), Race.HUMAN));
|
||||||
}
|
}
|
||||||
physics.fromNBT(compound);
|
physics.fromNBT(compound, lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -461,7 +461,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(NbtCompound compound, WrapperLookup lookup) {
|
public void toNBT(NbtCompound compound, WrapperLookup lookup) {
|
||||||
enchants.toNBT(compound);
|
enchants.toNBT(compound, lookup);
|
||||||
spells.getSlots().toNBT(compound, lookup);
|
spells.getSlots().toNBT(compound, lookup);
|
||||||
getCarrierId().ifPresent(id -> compound.putUuid("carrier", id));
|
getCarrierId().ifPresent(id -> compound.putUuid("carrier", id));
|
||||||
toSyncronisedNbt(compound, lookup);
|
toSyncronisedNbt(compound, lookup);
|
||||||
|
@ -469,7 +469,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(NbtCompound compound, WrapperLookup lookup) {
|
public void fromNBT(NbtCompound compound, WrapperLookup lookup) {
|
||||||
enchants.fromNBT(compound);
|
enchants.fromNBT(compound, lookup);
|
||||||
spells.getSlots().fromNBT(compound, lookup);
|
spells.getSlots().fromNBT(compound, lookup);
|
||||||
setCarrier(compound.containsUuid("carrier") ? compound.getUuid("carrier") : null);
|
setCarrier(compound.containsUuid("carrier") ? compound.getUuid("carrier") : null);
|
||||||
fromSynchronizedNbt(compound, lookup);
|
fromSynchronizedNbt(compound, lookup);
|
||||||
|
|
|
@ -53,7 +53,6 @@ import com.minelittlepony.unicopia.entity.collision.EntityCollisions;
|
||||||
import com.minelittlepony.unicopia.entity.collision.MultiBoundingBoxEntity;
|
import com.minelittlepony.unicopia.entity.collision.MultiBoundingBoxEntity;
|
||||||
import com.minelittlepony.unicopia.entity.collision.MultiBox;
|
import com.minelittlepony.unicopia.entity.collision.MultiBox;
|
||||||
import com.minelittlepony.unicopia.item.BasketItem;
|
import com.minelittlepony.unicopia.item.BasketItem;
|
||||||
import com.minelittlepony.unicopia.item.HotAirBalloonItem;
|
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
import com.minelittlepony.unicopia.item.UItems;
|
||||||
import com.minelittlepony.unicopia.item.component.UDataComponentTypes;
|
import com.minelittlepony.unicopia.item.component.UDataComponentTypes;
|
||||||
import com.minelittlepony.unicopia.server.world.WeatherConditions;
|
import com.minelittlepony.unicopia.server.world.WeatherConditions;
|
||||||
|
@ -370,7 +369,7 @@ public class AirBalloonEntity extends MobEntity implements EntityCollisions.Comp
|
||||||
protected ActionResult interactMob(PlayerEntity player, Hand hand) {
|
protected ActionResult interactMob(PlayerEntity player, Hand hand) {
|
||||||
ItemStack stack = player.getStackInHand(hand);
|
ItemStack stack = player.getStackInHand(hand);
|
||||||
|
|
||||||
if (stack.getItem() instanceof HotAirBalloonItem && !hasBalloon()) {
|
if (stack.contains(UDataComponentTypes.BALLOON_DESIGN) && !hasBalloon()) {
|
||||||
if (!player.getAbilities().creativeMode) {
|
if (!player.getAbilities().creativeMode) {
|
||||||
stack.decrement(1);
|
stack.decrement(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,6 +407,7 @@ public class ButterflyEntity extends AmbientEntity {
|
||||||
return VALUES[rand.nextInt(VALUES.length)];
|
return VALUES[rand.nextInt(VALUES.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static Variant byName(String name) {
|
public static Variant byName(String name) {
|
||||||
return CODEC.byId(name, BUTTERFLY);
|
return CODEC.byId(name, BUTTERFLY);
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,11 +247,11 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster<CastS
|
||||||
tag.putUuid("owningSpell", controllingSpellUuid);
|
tag.putUuid("owningSpell", controllingSpellUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
spells.getSlots().toNBT(tag, getWorld().getRegistryManager());
|
spells.getSlots().toNBT(tag, getRegistryManager());
|
||||||
tag.putInt("age", age);
|
tag.putInt("age", age);
|
||||||
tag.putInt("prevAge", prevAge);
|
tag.putInt("prevAge", prevAge);
|
||||||
tag.putBoolean("dead", isDead());
|
tag.putBoolean("dead", isDead());
|
||||||
tag.put("owner", owner.toNBT(getWorld().getRegistryManager()));
|
tag.put("owner", owner.toNBT(getRegistryManager()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -266,13 +266,13 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster<CastS
|
||||||
controllingEntityUuid = tag.containsUuid("owningEntity") ? tag.getUuid("owningEntity") : null;
|
controllingEntityUuid = tag.containsUuid("owningEntity") ? tag.getUuid("owningEntity") : null;
|
||||||
controllingSpellUuid = tag.containsUuid("owningSpell") ? tag.getUuid("owningSpell") : null;
|
controllingSpellUuid = tag.containsUuid("owningSpell") ? tag.getUuid("owningSpell") : null;
|
||||||
|
|
||||||
spells.getSlots().fromNBT(tag, getWorld().getRegistryManager());
|
spells.getSlots().fromNBT(tag, getRegistryManager());
|
||||||
age = tag.getInt("age");
|
age = tag.getInt("age");
|
||||||
prevAge = tag.getInt("prevAge");
|
prevAge = tag.getInt("prevAge");
|
||||||
setDead(tag.getBoolean("dead"));
|
setDead(tag.getBoolean("dead"));
|
||||||
|
|
||||||
if (tag.contains("owner")) {
|
if (tag.contains("owner")) {
|
||||||
owner.fromNBT(tag.getCompound("owner"), getWorld().getRegistryManager());
|
owner.fromNBT(tag.getCompound("owner"), getRegistryManager());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,7 @@ public class FairyEntity extends PathAwareEntity implements DynamicLightSource,
|
||||||
@Override
|
@Override
|
||||||
public void writeCustomDataToNbt(NbtCompound tag) {
|
public void writeCustomDataToNbt(NbtCompound tag) {
|
||||||
super.writeCustomDataToNbt(tag);
|
super.writeCustomDataToNbt(tag);
|
||||||
tag.put("owner", owner.toNBT(getWorld().getRegistryManager()));
|
tag.put("owner", owner.toNBT(getRegistryManager()));
|
||||||
stayingPos.ifPresent(pos -> {
|
stayingPos.ifPresent(pos -> {
|
||||||
tag.put("stayingPos", NbtHelper.fromBlockPos(pos));
|
tag.put("stayingPos", NbtHelper.fromBlockPos(pos));
|
||||||
});
|
});
|
||||||
|
@ -230,7 +230,7 @@ public class FairyEntity extends PathAwareEntity implements DynamicLightSource,
|
||||||
public void readCustomDataFromNbt(NbtCompound tag) {
|
public void readCustomDataFromNbt(NbtCompound tag) {
|
||||||
super.readCustomDataFromNbt(tag);
|
super.readCustomDataFromNbt(tag);
|
||||||
if (tag.contains("owner")) {
|
if (tag.contains("owner")) {
|
||||||
owner.fromNBT(tag.getCompound("owner"), getWorld().getRegistryManager());
|
owner.fromNBT(tag.getCompound("owner"), getRegistryManager());
|
||||||
}
|
}
|
||||||
stayingPos = tag.contains("stayingPos") ? NbtHelper.toBlockPos(tag, "stayingPos") : Optional.empty();
|
stayingPos = tag.contains("stayingPos") ? NbtHelper.toBlockPos(tag, "stayingPos") : Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ public class FloatingArtefactEntity extends StationaryObjectEntity {
|
||||||
@Override
|
@Override
|
||||||
protected void readCustomDataFromNbt(NbtCompound compound) {
|
protected void readCustomDataFromNbt(NbtCompound compound) {
|
||||||
super.readCustomDataFromNbt(compound);
|
super.readCustomDataFromNbt(compound);
|
||||||
setStack(ItemStack.fromNbtOrEmpty(getWorld().getRegistryManager(), compound.getCompound("Item")));
|
setStack(ItemStack.fromNbtOrEmpty(getRegistryManager(), compound.getCompound("Item")));
|
||||||
setState(State.valueOf(compound.getInt("State")));
|
setState(State.valueOf(compound.getInt("State")));
|
||||||
setRotationSpeed(compound.getFloat("spin"), compound.getInt("spinDuration"));
|
setRotationSpeed(compound.getFloat("spin"), compound.getInt("spinDuration"));
|
||||||
ticksUntilRegen = compound.getInt("regen");
|
ticksUntilRegen = compound.getInt("regen");
|
||||||
|
|
|
@ -340,7 +340,7 @@ public class IgnominiousBulbEntity extends MobEntity {
|
||||||
getTentacles().forEach((pos, tentacle) -> {
|
getTentacles().forEach((pos, tentacle) -> {
|
||||||
var compound = new NbtCompound();
|
var compound = new NbtCompound();
|
||||||
compound.put("pos", NbtHelper.fromBlockPos(pos));
|
compound.put("pos", NbtHelper.fromBlockPos(pos));
|
||||||
compound.put("target", tentacle.toNBT(getWorld().getRegistryManager()));
|
compound.put("target", tentacle.toNBT(getRegistryManager()));
|
||||||
tentacles.add(compound);
|
tentacles.add(compound);
|
||||||
});
|
});
|
||||||
nbt.put("tentacles", tentacles);
|
nbt.put("tentacles", tentacles);
|
||||||
|
@ -357,7 +357,7 @@ public class IgnominiousBulbEntity extends MobEntity {
|
||||||
nbt.getList("tentacles", NbtElement.COMPOUND_TYPE).forEach(tag -> {
|
nbt.getList("tentacles", NbtElement.COMPOUND_TYPE).forEach(tag -> {
|
||||||
var compound = (NbtCompound)tag;
|
var compound = (NbtCompound)tag;
|
||||||
NbtHelper.toBlockPos(compound, "pos").ifPresent(pos -> {
|
NbtHelper.toBlockPos(compound, "pos").ifPresent(pos -> {
|
||||||
tentacles.put(pos, new EntityReference<>(compound.getCompound("target"), getWorld().getRegistryManager()));
|
tentacles.put(pos, new EntityReference<>(compound.getCompound("target"), getRegistryManager()));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.tentacles = tentacles;
|
this.tentacles = tentacles;
|
||||||
|
|
|
@ -328,7 +328,7 @@ public class MimicEntity extends PathAwareEntity {
|
||||||
@Nullable
|
@Nullable
|
||||||
private ChestBlockEntity readChestData(NbtCompound nbt) {
|
private ChestBlockEntity readChestData(NbtCompound nbt) {
|
||||||
BlockState state = BlockState.CODEC.decode(NbtOps.INSTANCE, nbt.getCompound("state")).result().get().getFirst();
|
BlockState state = BlockState.CODEC.decode(NbtOps.INSTANCE, nbt.getCompound("state")).result().get().getFirst();
|
||||||
if (BlockEntity.createFromNbt(getBlockPos(), state, nbt.getCompound("data"), getWorld().getRegistryManager()) instanceof ChestBlockEntity data) {
|
if (BlockEntity.createFromNbt(getBlockPos(), state, nbt.getCompound("data"), getRegistryManager()) instanceof ChestBlockEntity data) {
|
||||||
data.setWorld(getWorld());
|
data.setWorld(getWorld());
|
||||||
((MimicGeneratable)data).setAllowMimics(false);
|
((MimicGeneratable)data).setAllowMimics(false);
|
||||||
return data;
|
return data;
|
||||||
|
@ -347,7 +347,7 @@ public class MimicEntity extends PathAwareEntity {
|
||||||
@Nullable
|
@Nullable
|
||||||
private NbtCompound writeChestData(ChestBlockEntity chestData) {
|
private NbtCompound writeChestData(ChestBlockEntity chestData) {
|
||||||
NbtCompound chest = new NbtCompound();
|
NbtCompound chest = new NbtCompound();
|
||||||
chest.put("data", chestData.createNbtWithId(getWorld().getRegistryManager()));
|
chest.put("data", chestData.createNbtWithId(getRegistryManager()));
|
||||||
chest.put("state", BlockState.CODEC.encode(chestData.getCachedState(), NbtOps.INSTANCE, new NbtCompound()).result().get());
|
chest.put("state", BlockState.CODEC.encode(chestData.getCachedState(), NbtOps.INSTANCE, new NbtCompound()).result().get());
|
||||||
return chest;
|
return chest;
|
||||||
}
|
}
|
||||||
|
|
|
@ -676,7 +676,7 @@ public class SombraEntity extends HostileEntity implements ArenaCombatant, Parti
|
||||||
getHomePos().map(NbtHelper::fromBlockPos).ifPresent(pos -> {
|
getHomePos().map(NbtHelper::fromBlockPos).ifPresent(pos -> {
|
||||||
nbt.put("homePos", pos);
|
nbt.put("homePos", pos);
|
||||||
});
|
});
|
||||||
nbt.put("cloud", stormCloud.toNBT(getWorld().getRegistryManager()));
|
nbt.put("cloud", stormCloud.toNBT(getRegistryManager()));
|
||||||
nbt.putFloat("size", getScaleFactor());
|
nbt.putFloat("size", getScaleFactor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -690,7 +690,7 @@ public class SombraEntity extends HostileEntity implements ArenaCombatant, Parti
|
||||||
bossBar.setName(getDisplayName());
|
bossBar.setName(getDisplayName());
|
||||||
}
|
}
|
||||||
setScaleFactor(nbt.getFloat("size"));
|
setScaleFactor(nbt.getFloat("size"));
|
||||||
stormCloud.fromNBT(nbt.getCompound("cloud"), getWorld().getRegistryManager());
|
stormCloud.fromNBT(nbt.getCompound("cloud"), getRegistryManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SombraBossBar extends ServerBossBar {
|
private static class SombraBossBar extends ServerBossBar {
|
||||||
|
|
|
@ -307,7 +307,7 @@ public class StormCloudEntity extends Entity implements MagicImmune {
|
||||||
if (source.getAttacker() instanceof PlayerEntity player) {
|
if (source.getAttacker() instanceof PlayerEntity player) {
|
||||||
builder = builder.add(LootContextParameters.LAST_DAMAGE_PLAYER, player).luck(player.getLuck());
|
builder = builder.add(LootContextParameters.LAST_DAMAGE_PLAYER, player).luck(player.getLuck());
|
||||||
}
|
}
|
||||||
getWorld().getRegistryManager().get(RegistryKeys.LOOT_TABLE).get(table)
|
getRegistryManager().get(RegistryKeys.LOOT_TABLE).get(table)
|
||||||
.generateLoot(builder.build(LootContextTypes.ENTITY), 0L, this::dropStack);
|
.generateLoot(builder.build(LootContextTypes.ENTITY), 0L, this::dropStack);
|
||||||
}
|
}
|
||||||
kill();
|
kill();
|
||||||
|
|
|
@ -179,8 +179,8 @@ public class MagicBeamEntity extends MagicProjectileEntity implements Caster<Mag
|
||||||
public void readCustomDataFromNbt(NbtCompound compound) {
|
public void readCustomDataFromNbt(NbtCompound compound) {
|
||||||
super.readCustomDataFromNbt(compound);
|
super.readCustomDataFromNbt(compound);
|
||||||
getDataTracker().set(HYDROPHOBIC, compound.getBoolean("hydrophobic"));
|
getDataTracker().set(HYDROPHOBIC, compound.getBoolean("hydrophobic"));
|
||||||
physics.fromNBT(compound);
|
physics.fromNBT(compound, getRegistryManager());
|
||||||
spells.getSlots().fromNBT(compound, getWorld().getRegistryManager());
|
spells.getSlots().fromNBT(compound, getRegistryManager());
|
||||||
var level = Levelled.fromNbt(compound.getCompound("level"));
|
var level = Levelled.fromNbt(compound.getCompound("level"));
|
||||||
dataTracker.set(MAX_LEVEL, level.getMax());
|
dataTracker.set(MAX_LEVEL, level.getMax());
|
||||||
dataTracker.set(LEVEL, level.get());
|
dataTracker.set(LEVEL, level.get());
|
||||||
|
@ -195,7 +195,7 @@ public class MagicBeamEntity extends MagicProjectileEntity implements Caster<Mag
|
||||||
compound.put("level", level.toNbt());
|
compound.put("level", level.toNbt());
|
||||||
compound.put("corruption", corruption.toNbt());
|
compound.put("corruption", corruption.toNbt());
|
||||||
compound.putBoolean("hydrophobic", getHydrophobic());
|
compound.putBoolean("hydrophobic", getHydrophobic());
|
||||||
physics.toNBT(compound);
|
physics.toNBT(compound, getRegistryManager());
|
||||||
spells.getSlots().toNBT(compound, getWorld().getRegistryManager());
|
spells.getSlots().toNBT(compound, getRegistryManager());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,8 +176,8 @@ public class MagicProjectileEntity extends ThrownItemEntity implements WeaklyOwn
|
||||||
@Override
|
@Override
|
||||||
public void readCustomDataFromNbt(NbtCompound compound) {
|
public void readCustomDataFromNbt(NbtCompound compound) {
|
||||||
super.readCustomDataFromNbt(compound);
|
super.readCustomDataFromNbt(compound);
|
||||||
homingTarget.fromNBT(compound.getCompound("homingTarget"), getWorld().getRegistryManager());
|
homingTarget.fromNBT(compound.getCompound("homingTarget"), getRegistryManager());
|
||||||
getMasterReference().fromNBT(compound.getCompound("owner"), getWorld().getRegistryManager());
|
getMasterReference().fromNBT(compound.getCompound("owner"), getRegistryManager());
|
||||||
if (compound.contains("maxAge", NbtElement.INT_TYPE)) {
|
if (compound.contains("maxAge", NbtElement.INT_TYPE)) {
|
||||||
maxAge = compound.getInt("maxAge");
|
maxAge = compound.getInt("maxAge");
|
||||||
}
|
}
|
||||||
|
@ -186,8 +186,8 @@ public class MagicProjectileEntity extends ThrownItemEntity implements WeaklyOwn
|
||||||
@Override
|
@Override
|
||||||
public void writeCustomDataToNbt(NbtCompound compound) {
|
public void writeCustomDataToNbt(NbtCompound compound) {
|
||||||
super.writeCustomDataToNbt(compound);
|
super.writeCustomDataToNbt(compound);
|
||||||
compound.put("homingTarget", homingTarget.toNBT(getWorld().getRegistryManager()));
|
compound.put("homingTarget", homingTarget.toNBT(getRegistryManager()));
|
||||||
compound.put("owner", getMasterReference().toNBT(getWorld().getRegistryManager()));
|
compound.put("owner", getMasterReference().toNBT(getRegistryManager()));
|
||||||
compound.putInt("maxAge", maxAge);
|
compound.putInt("maxAge", maxAge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DamageSources getDamageSources() {
|
public DamageSources getDamageSources() {
|
||||||
return new DamageSources(getWorld().getRegistryManager()) {
|
return new DamageSources(getRegistryManager()) {
|
||||||
@Override
|
@Override
|
||||||
public DamageSource arrow(PersistentProjectileEntity source, @Nullable Entity attacker) {
|
public DamageSource arrow(PersistentProjectileEntity source, @Nullable Entity attacker) {
|
||||||
return create(damageType, source, attacker);
|
return create(damageType, source, attacker);
|
||||||
|
@ -299,7 +299,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
||||||
@Override
|
@Override
|
||||||
public void readCustomDataFromNbt(NbtCompound nbt) {
|
public void readCustomDataFromNbt(NbtCompound nbt) {
|
||||||
super.readCustomDataFromNbt(nbt);
|
super.readCustomDataFromNbt(nbt);
|
||||||
setStack(ItemStack.fromNbtOrEmpty(getWorld().getRegistryManager(), nbt.getCompound("Item")));
|
setStack(ItemStack.fromNbtOrEmpty(getRegistryManager(), nbt.getCompound("Item")));
|
||||||
if (nbt.contains("damageType", NbtElement.STRING_TYPE)) {
|
if (nbt.contains("damageType", NbtElement.STRING_TYPE)) {
|
||||||
Optional.ofNullable(Identifier.tryParse(nbt.getString("damageType"))).ifPresent(id -> {
|
Optional.ofNullable(Identifier.tryParse(nbt.getString("damageType"))).ifPresent(id -> {
|
||||||
setDamageType(RegistryKey.of(RegistryKeys.DAMAGE_TYPE, id));
|
setDamageType(RegistryKey.of(RegistryKeys.DAMAGE_TYPE, id));
|
||||||
|
|
Loading…
Reference in a new issue