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
|
||||
public void toNBT(NbtCompound compound, WrapperLookup lookup) {
|
||||
compound.putString("owner_race", getSpecies().getId().toString());
|
||||
physics.toNBT(compound);
|
||||
physics.toNBT(compound, lookup);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -165,7 +165,7 @@ public class ItemImpl implements Equine<ItemEntity> {
|
|||
if (compound.contains("owner_race", NbtElement.STRING_TYPE)) {
|
||||
setSpecies(Race.fromName(compound.getString("owner_race"), Race.HUMAN));
|
||||
}
|
||||
physics.fromNBT(compound);
|
||||
physics.fromNBT(compound, lookup);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -461,7 +461,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
|||
|
||||
@Override
|
||||
public void toNBT(NbtCompound compound, WrapperLookup lookup) {
|
||||
enchants.toNBT(compound);
|
||||
enchants.toNBT(compound, lookup);
|
||||
spells.getSlots().toNBT(compound, lookup);
|
||||
getCarrierId().ifPresent(id -> compound.putUuid("carrier", id));
|
||||
toSyncronisedNbt(compound, lookup);
|
||||
|
@ -469,7 +469,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
|||
|
||||
@Override
|
||||
public void fromNBT(NbtCompound compound, WrapperLookup lookup) {
|
||||
enchants.fromNBT(compound);
|
||||
enchants.fromNBT(compound, lookup);
|
||||
spells.getSlots().fromNBT(compound, lookup);
|
||||
setCarrier(compound.containsUuid("carrier") ? compound.getUuid("carrier") : null);
|
||||
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.MultiBox;
|
||||
import com.minelittlepony.unicopia.item.BasketItem;
|
||||
import com.minelittlepony.unicopia.item.HotAirBalloonItem;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
import com.minelittlepony.unicopia.item.component.UDataComponentTypes;
|
||||
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) {
|
||||
ItemStack stack = player.getStackInHand(hand);
|
||||
|
||||
if (stack.getItem() instanceof HotAirBalloonItem && !hasBalloon()) {
|
||||
if (stack.contains(UDataComponentTypes.BALLOON_DESIGN) && !hasBalloon()) {
|
||||
if (!player.getAbilities().creativeMode) {
|
||||
stack.decrement(1);
|
||||
}
|
||||
|
|
|
@ -407,6 +407,7 @@ public class ButterflyEntity extends AmbientEntity {
|
|||
return VALUES[rand.nextInt(VALUES.length)];
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Variant byName(String name) {
|
||||
return CODEC.byId(name, BUTTERFLY);
|
||||
}
|
||||
|
|
|
@ -247,11 +247,11 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster<CastS
|
|||
tag.putUuid("owningSpell", controllingSpellUuid);
|
||||
}
|
||||
|
||||
spells.getSlots().toNBT(tag, getWorld().getRegistryManager());
|
||||
spells.getSlots().toNBT(tag, getRegistryManager());
|
||||
tag.putInt("age", age);
|
||||
tag.putInt("prevAge", prevAge);
|
||||
tag.putBoolean("dead", isDead());
|
||||
tag.put("owner", owner.toNBT(getWorld().getRegistryManager()));
|
||||
tag.put("owner", owner.toNBT(getRegistryManager()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -266,13 +266,13 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster<CastS
|
|||
controllingEntityUuid = tag.containsUuid("owningEntity") ? tag.getUuid("owningEntity") : null;
|
||||
controllingSpellUuid = tag.containsUuid("owningSpell") ? tag.getUuid("owningSpell") : null;
|
||||
|
||||
spells.getSlots().fromNBT(tag, getWorld().getRegistryManager());
|
||||
spells.getSlots().fromNBT(tag, getRegistryManager());
|
||||
age = tag.getInt("age");
|
||||
prevAge = tag.getInt("prevAge");
|
||||
setDead(tag.getBoolean("dead"));
|
||||
|
||||
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
|
||||
public void writeCustomDataToNbt(NbtCompound tag) {
|
||||
super.writeCustomDataToNbt(tag);
|
||||
tag.put("owner", owner.toNBT(getWorld().getRegistryManager()));
|
||||
tag.put("owner", owner.toNBT(getRegistryManager()));
|
||||
stayingPos.ifPresent(pos -> {
|
||||
tag.put("stayingPos", NbtHelper.fromBlockPos(pos));
|
||||
});
|
||||
|
@ -230,7 +230,7 @@ public class FairyEntity extends PathAwareEntity implements DynamicLightSource,
|
|||
public void readCustomDataFromNbt(NbtCompound tag) {
|
||||
super.readCustomDataFromNbt(tag);
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public class FloatingArtefactEntity extends StationaryObjectEntity {
|
|||
@Override
|
||||
protected void readCustomDataFromNbt(NbtCompound 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")));
|
||||
setRotationSpeed(compound.getFloat("spin"), compound.getInt("spinDuration"));
|
||||
ticksUntilRegen = compound.getInt("regen");
|
||||
|
|
|
@ -340,7 +340,7 @@ public class IgnominiousBulbEntity extends MobEntity {
|
|||
getTentacles().forEach((pos, tentacle) -> {
|
||||
var compound = new NbtCompound();
|
||||
compound.put("pos", NbtHelper.fromBlockPos(pos));
|
||||
compound.put("target", tentacle.toNBT(getWorld().getRegistryManager()));
|
||||
compound.put("target", tentacle.toNBT(getRegistryManager()));
|
||||
tentacles.add(compound);
|
||||
});
|
||||
nbt.put("tentacles", tentacles);
|
||||
|
@ -357,7 +357,7 @@ public class IgnominiousBulbEntity extends MobEntity {
|
|||
nbt.getList("tentacles", NbtElement.COMPOUND_TYPE).forEach(tag -> {
|
||||
var compound = (NbtCompound)tag;
|
||||
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;
|
||||
|
|
|
@ -328,7 +328,7 @@ public class MimicEntity extends PathAwareEntity {
|
|||
@Nullable
|
||||
private ChestBlockEntity readChestData(NbtCompound nbt) {
|
||||
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());
|
||||
((MimicGeneratable)data).setAllowMimics(false);
|
||||
return data;
|
||||
|
@ -347,7 +347,7 @@ public class MimicEntity extends PathAwareEntity {
|
|||
@Nullable
|
||||
private NbtCompound writeChestData(ChestBlockEntity chestData) {
|
||||
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());
|
||||
return chest;
|
||||
}
|
||||
|
|
|
@ -676,7 +676,7 @@ public class SombraEntity extends HostileEntity implements ArenaCombatant, Parti
|
|||
getHomePos().map(NbtHelper::fromBlockPos).ifPresent(pos -> {
|
||||
nbt.put("homePos", pos);
|
||||
});
|
||||
nbt.put("cloud", stormCloud.toNBT(getWorld().getRegistryManager()));
|
||||
nbt.put("cloud", stormCloud.toNBT(getRegistryManager()));
|
||||
nbt.putFloat("size", getScaleFactor());
|
||||
}
|
||||
|
||||
|
@ -690,7 +690,7 @@ public class SombraEntity extends HostileEntity implements ArenaCombatant, Parti
|
|||
bossBar.setName(getDisplayName());
|
||||
}
|
||||
setScaleFactor(nbt.getFloat("size"));
|
||||
stormCloud.fromNBT(nbt.getCompound("cloud"), getWorld().getRegistryManager());
|
||||
stormCloud.fromNBT(nbt.getCompound("cloud"), getRegistryManager());
|
||||
}
|
||||
|
||||
private static class SombraBossBar extends ServerBossBar {
|
||||
|
|
|
@ -307,7 +307,7 @@ public class StormCloudEntity extends Entity implements MagicImmune {
|
|||
if (source.getAttacker() instanceof PlayerEntity player) {
|
||||
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);
|
||||
}
|
||||
kill();
|
||||
|
|
|
@ -179,8 +179,8 @@ public class MagicBeamEntity extends MagicProjectileEntity implements Caster<Mag
|
|||
public void readCustomDataFromNbt(NbtCompound compound) {
|
||||
super.readCustomDataFromNbt(compound);
|
||||
getDataTracker().set(HYDROPHOBIC, compound.getBoolean("hydrophobic"));
|
||||
physics.fromNBT(compound);
|
||||
spells.getSlots().fromNBT(compound, getWorld().getRegistryManager());
|
||||
physics.fromNBT(compound, getRegistryManager());
|
||||
spells.getSlots().fromNBT(compound, getRegistryManager());
|
||||
var level = Levelled.fromNbt(compound.getCompound("level"));
|
||||
dataTracker.set(MAX_LEVEL, level.getMax());
|
||||
dataTracker.set(LEVEL, level.get());
|
||||
|
@ -195,7 +195,7 @@ public class MagicBeamEntity extends MagicProjectileEntity implements Caster<Mag
|
|||
compound.put("level", level.toNbt());
|
||||
compound.put("corruption", corruption.toNbt());
|
||||
compound.putBoolean("hydrophobic", getHydrophobic());
|
||||
physics.toNBT(compound);
|
||||
spells.getSlots().toNBT(compound, getWorld().getRegistryManager());
|
||||
physics.toNBT(compound, getRegistryManager());
|
||||
spells.getSlots().toNBT(compound, getRegistryManager());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,8 +176,8 @@ public class MagicProjectileEntity extends ThrownItemEntity implements WeaklyOwn
|
|||
@Override
|
||||
public void readCustomDataFromNbt(NbtCompound compound) {
|
||||
super.readCustomDataFromNbt(compound);
|
||||
homingTarget.fromNBT(compound.getCompound("homingTarget"), getWorld().getRegistryManager());
|
||||
getMasterReference().fromNBT(compound.getCompound("owner"), getWorld().getRegistryManager());
|
||||
homingTarget.fromNBT(compound.getCompound("homingTarget"), getRegistryManager());
|
||||
getMasterReference().fromNBT(compound.getCompound("owner"), getRegistryManager());
|
||||
if (compound.contains("maxAge", NbtElement.INT_TYPE)) {
|
||||
maxAge = compound.getInt("maxAge");
|
||||
}
|
||||
|
@ -186,8 +186,8 @@ public class MagicProjectileEntity extends ThrownItemEntity implements WeaklyOwn
|
|||
@Override
|
||||
public void writeCustomDataToNbt(NbtCompound compound) {
|
||||
super.writeCustomDataToNbt(compound);
|
||||
compound.put("homingTarget", homingTarget.toNBT(getWorld().getRegistryManager()));
|
||||
compound.put("owner", getMasterReference().toNBT(getWorld().getRegistryManager()));
|
||||
compound.put("homingTarget", homingTarget.toNBT(getRegistryManager()));
|
||||
compound.put("owner", getMasterReference().toNBT(getRegistryManager()));
|
||||
compound.putInt("maxAge", maxAge);
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
|||
|
||||
@Override
|
||||
public DamageSources getDamageSources() {
|
||||
return new DamageSources(getWorld().getRegistryManager()) {
|
||||
return new DamageSources(getRegistryManager()) {
|
||||
@Override
|
||||
public DamageSource arrow(PersistentProjectileEntity source, @Nullable Entity attacker) {
|
||||
return create(damageType, source, attacker);
|
||||
|
@ -299,7 +299,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl
|
|||
@Override
|
||||
public void readCustomDataFromNbt(NbtCompound 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)) {
|
||||
Optional.ofNullable(Identifier.tryParse(nbt.getString("damageType"))).ifPresent(id -> {
|
||||
setDamageType(RegistryKey.of(RegistryKeys.DAMAGE_TYPE, id));
|
||||
|
|
Loading…
Reference in a new issue