1.19.2 -> 1.18.2

This commit is contained in:
Sollace 2022-09-15 01:48:40 +02:00
parent 83832a540b
commit 9b08e17010
99 changed files with 324 additions and 321 deletions

View file

@ -15,6 +15,7 @@ import net.minecraft.command.argument.RegistryKeyArgumentType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
@ -23,7 +24,7 @@ public final class Race implements Affine {
public static final String DEFAULT_ID = "unicopia:human";
public static final Registry<Race> REGISTRY = Registries.createDefaulted(Unicopia.id("race"), DEFAULT_ID);
public static final RegistryKey<? extends Registry<Race>> REGISTRY_KEY = REGISTRY.getKey();
private static final DynamicCommandExceptionType UNKNOWN_RACE_EXCEPTION = new DynamicCommandExceptionType(id -> Text.translatable("race.unknown", id));
private static final DynamicCommandExceptionType UNKNOWN_RACE_EXCEPTION = new DynamicCommandExceptionType(id -> new TranslatableText("race.unknown", id));
public static Race register(String name, boolean magic, FlightType flight, boolean earth) {
return register(Unicopia.id(name), magic, flight, earth);
@ -103,11 +104,11 @@ public final class Race implements Affine {
}
public Text getDisplayName() {
return Text.translatable(getTranslationKey());
return new TranslatableText(getTranslationKey());
}
public Text getAltDisplayName() {
return Text.translatable(getTranslationKey() + ".alt");
return new TranslatableText(getTranslationKey() + ".alt");
}
public String getTranslationKey() {

View file

@ -5,7 +5,6 @@ import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.world.PersistentState;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.dimension.DimensionTypes;
public class WorldTribeManager extends PersistentState {
@ -32,13 +31,13 @@ public class WorldTribeManager extends PersistentState {
}
public static String nameFor(RegistryEntry<DimensionType> dimension) {
if (dimension.matchesKey(DimensionTypes.THE_END)) {
if (dimension.matchesKey(DimensionType.THE_END_REGISTRY_KEY)) {
return "unicopia:tribes_end";
}
return "unicopia:tribes";
}
public static WorldTribeManager forWorld(ServerWorld world) {
return world.getPersistentStateManager().getOrCreate(WorldTribeManager::new, WorldTribeManager::new, nameFor(world.getDimensionEntry()));
return world.getPersistentStateManager().getOrCreate(WorldTribeManager::new, WorldTribeManager::new, nameFor(world.method_40134()));
}
}

View file

@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
@ -78,7 +79,7 @@ public interface Ability<T extends Hit> {
*/
default Text getName() {
Identifier id = Abilities.REGISTRY.getId(this);
return Text.translatable("ability." + id.getNamespace() + "." + id.getPath().replace('/', '.'));
return new TranslatableText("ability." + id.getNamespace() + "." + id.getPath().replace('/', '.'));
}
/**

View file

@ -1,5 +1,7 @@
package com.minelittlepony.unicopia.ability;
import java.util.Random;
import com.minelittlepony.unicopia.AwaitTickQueue;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Race;
@ -13,7 +15,6 @@ import com.minelittlepony.unicopia.util.MagicalDamageSource;
import net.minecraft.entity.LivingEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
/**
* A magic casting ability for unicorns.

View file

@ -77,7 +77,7 @@ public class EarthPonyKickAbility implements Ability<Pos> {
for (var e : VecHelper.findInRange(player.getEntity(), w, kickLocation.vec(), 2, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR)) {
if (e instanceof LivingEntity entity) {
float calculatedStrength = 0.5F * (1 + player.getLevel().getScaled(9));
entity.damage(MagicalDamageSource.KICK, player.getReferenceWorld().random.nextBetween(2, 10) + calculatedStrength);
entity.damage(MagicalDamageSource.KICK, 2 + player.getReferenceWorld().random.nextInt(8) + calculatedStrength);
entity.takeKnockback(calculatedStrength, origin.x - entity.getX(), origin.z - entity.getZ());
player.subtractEnergyCost(3);
player.setAnimation(Animation.KICK);

View file

@ -189,7 +189,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
ItemStack stack = UItems.PEBBLES.getDefaultStack();
stack.setCount(1 + w.getRandom().nextInt(2));
Block.dropStack(w, pos, stack);
state.onStacksDropped((ServerWorld)w, pos, stack, true);
state.onStacksDropped((ServerWorld)w, pos, stack);
}
}
} else {

View file

@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import net.minecraft.world.level.ServerWorldProperties;
@ -109,7 +109,7 @@ public class PegasusCaptureStormAbility implements Ability<Hit> {
}
private void tell(Pony player, String translation) {
player.getMaster().sendMessage(Text.translatable(translation), true);
player.getMaster().sendMessage(new TranslatableText(translation), true);
}
@Override

View file

@ -1,5 +1,7 @@
package com.minelittlepony.unicopia.ability;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
@ -24,7 +26,6 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
/**
* Casts magic onto the user directly, or uses the item in the main hand slot.

View file

@ -13,7 +13,7 @@ import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.util.RayTraceHelper;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
/**
* Dispells an active spell
@ -46,9 +46,9 @@ public class UnicornDispellAbility implements Ability<Pos> {
if (type.getTapCount() > 1) {
player.setAnimation(Animation.WOLOLO, 10);
if (player.getSpellSlot().clear()) {
player.getMaster().sendMessage(Text.translatable("gui.unicopia.action.spells_cleared"), true);
player.getMaster().sendMessage(new TranslatableText("gui.unicopia.action.spells_cleared"), true);
} else {
player.getMaster().sendMessage(Text.translatable("gui.unicopia.action.no_spells_cleared"), true);
player.getMaster().sendMessage(new TranslatableText("gui.unicopia.action.no_spells_cleared"), true);
}
return true;
}

View file

@ -38,7 +38,7 @@ public class InfernoSpell extends FireSpell {
Vec3d origin = source.getOriginVector();
BlockStateConverter converter = w.getDimension().ultrawarm() ? StateMaps.HELLFIRE_AFFECTED.getInverse() : StateMaps.HELLFIRE_AFFECTED;
BlockStateConverter converter = w.getDimension().isUltrawarm() ? StateMaps.HELLFIRE_AFFECTED.getInverse() : StateMaps.HELLFIRE_AFFECTED;
for (int i = 0; i < radius; i++) {
BlockPos pos = new BlockPos(shape.computePoint(w.random).add(origin));

View file

@ -111,12 +111,12 @@ public class PortalSpell extends AbstractSpell implements PlaceableSpell.Placeme
destination.entity.getPosition().ifPresent(targetPos -> {
source.findAllEntitiesInRange(1).forEach(entity -> {
if (!entity.hasPortalCooldown() && entity.timeUntilRegen <= 0) {
if (!entity.hasNetherPortalCooldown() && entity.timeUntilRegen <= 0) {
Vec3d offset = entity.getPos().subtract(source.getOriginVector());
float yawDifference = pitch < 15 ? (180 - yaw + destination.yaw) : 0;
Vec3d dest = targetPos.add(offset.rotateY(yawDifference * MathHelper.RADIANS_PER_DEGREE)).add(0, 0.05, 0);
entity.resetPortalCooldown();
entity.resetNetherPortalCooldown();
entity.timeUntilRegen = 100;
entity.setYaw(entity.getYaw() + yawDifference);

View file

@ -25,6 +25,7 @@ import com.minelittlepony.unicopia.util.Registries;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.registry.Registry;
@ -127,7 +128,7 @@ public final class SpellType<T extends Spell> implements Affine, SpellPredicate<
}
public Text getName() {
return Text.translatable(getTranslationKey());
return new TranslatableText(getTranslationKey());
}
public CustomisedSpellType<T> withTraits() {

View file

@ -91,14 +91,14 @@ public enum Trait {
: Formatting.WHITE;
return Tooltip.of(
Text.translatable("gui.unicopia.trait.label",
Text.translatable("trait." + getId().getNamespace() + "." + getId().getPath() + ".name")
new TranslatableText("gui.unicopia.trait.label",
new TranslatableText("trait." + getId().getNamespace() + "." + getId().getPath() + ".name")
).formatted(Formatting.YELLOW)
.append(Text.translatable("gui.unicopia.trait.group", getGroup().name().toLowerCase()).formatted(Formatting.ITALIC, Formatting.GRAY))
.append(Text.literal("\n\n").formatted(Formatting.WHITE)
.append(Text.translatable("trait." + getId().getNamespace() + "." + getId().getPath() + ".description").formatted(Formatting.GRAY))
.append(new TranslatableText("gui.unicopia.trait.group", getGroup().name().toLowerCase()).formatted(Formatting.ITALIC, Formatting.GRAY))
.append(new LiteralText("\n\n").formatted(Formatting.WHITE)
.append(new TranslatableText("trait." + getId().getNamespace() + "." + getId().getPath() + ".description").formatted(Formatting.GRAY))
.append("\n")
.append(Text.translatable("gui.unicopia.trait.corruption", ItemStack.MODIFIER_FORMAT.format(getGroup().getCorruption())).formatted(Formatting.ITALIC, corruptionColor))), 200);
.append(new TranslatableText("gui.unicopia.trait.corruption", ItemStack.MODIFIER_FORMAT.format(getGroup().getCorruption())).formatted(Formatting.ITALIC, corruptionColor))), 200);
}
public static Collection<Trait> all() {

View file

@ -42,7 +42,7 @@ public class TraitLoader extends SinglePreparationResourceReloader<Multimap<Iden
Multimap<Identifier, TraitStream> prepared = HashMultimap.create();
for (var path : manager.findResources("traits", p -> p.getPath().endsWith(".json")).keySet()) {
for (var path : manager.findResources("traits", p -> p.endsWith(".json"))) {
profiler.push(path.toString());
try {
for (Resource resource : manager.getAllResources(path)) {

View file

@ -28,7 +28,7 @@ public class FrostedObsidianBlock extends FrostedIceBlock {
@Override
protected void melt(BlockState state, World world, BlockPos pos) {
if (world.getDimension().ultrawarm()) {
if (world.getDimension().isUltrawarm()) {
world.removeBlock(pos, false);
return;
}

View file

@ -1,5 +1,7 @@
package com.minelittlepony.unicopia.block;
import java.util.Random;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.item.UItems;
@ -9,7 +11,6 @@ import net.minecraft.block.ShapeContext;
import net.minecraft.item.ItemConvertible;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;

View file

@ -1,6 +1,7 @@
package com.minelittlepony.unicopia.block.state;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
@ -48,34 +49,37 @@ public class StateMapLoader extends JsonDataLoader implements IdentifiableResour
Map<Identifier, JsonElement> map = Maps.newHashMap();
int i = DATA_TYPE.length() + 1;
resourceManager.findAllResources(DATA_TYPE, id -> id.getPath().endsWith(FILE_SUFFIX)).entrySet().stream().forEach(entry -> {
Identifier resId = entry.getKey();
resourceManager.findResources(DATA_TYPE, id -> id.endsWith(FILE_SUFFIX)).stream().forEach(entry -> {
Identifier resId = entry;
String path = resId.getPath();
Identifier id = new Identifier(resId.getNamespace(), path.substring(i, path.length() - FILE_SUFFIX_LENGTH));
JsonArray entries = new JsonArray();
for (var resource : entry.getValue()) {
try (BufferedReader reader = resource.getReader()) {
JsonObject json = JsonHelper.deserialize(Resources.GSON, reader, JsonObject.class);
try {
for (var resource : resourceManager.getAllResources(entry)) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8))) {
JsonObject json = JsonHelper.deserialize(Resources.GSON, reader, JsonObject.class);
if (json != null) {
if (json.has("entries")) {
if (json != null) {
if (json.has("entries")) {
JsonArray incoming = JsonHelper.getArray(json, "entries");
if (json.has("replace") && json.get("replace").getAsBoolean()) {
entries = incoming;
} else {
entries.addAll(incoming);
JsonArray incoming = JsonHelper.getArray(json, "entries");
if (json.has("replace") && json.get("replace").getAsBoolean()) {
entries = incoming;
} else {
entries.addAll(incoming);
}
}
continue;
}
continue;
LOGGER.error("Couldn't load data file {} from {} as it's null or empty", id, resId);
} catch (JsonParseException | IOException | IllegalArgumentException e) {
LOGGER.error("Couldn't parse data file {} from {}", id, resId, e);
}
LOGGER.error("Couldn't load data file {} from {} as it's null or empty", id, resId);
} catch (JsonParseException | IOException | IllegalArgumentException e) {
LOGGER.error("Couldn't parse data file {} from {}", id, resId, e);
}
} catch (IOException e) {
}
map.put(id, entries);

View file

@ -1,5 +1,6 @@
package com.minelittlepony.unicopia.client;
import java.util.Random;
import java.util.function.Predicate;
import org.jetbrains.annotations.NotNull;
@ -33,7 +34,6 @@ import net.minecraft.entity.passive.BeeEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
public class ClientInteractionManager extends InteractionManager {
@ -60,7 +60,7 @@ public class ClientInteractionManager extends InteractionManager {
if (type == SOUND_EARS_RINGING && source instanceof LivingEntity) {
soundManager.play(new LoopingSoundInstance<>((LivingEntity)source,
createTicker(100).and(e -> e.hasStatusEffect(UEffects.SUN_BLINDNESS)),
USounds.ENTITY_PLAYER_EARS_RINGING, 0.01F, 2, Random.create(seed)).setFadeIn()
USounds.ENTITY_PLAYER_EARS_RINGING, 0.01F, 2, new Random(seed)).setFadeIn()
);
} else if (type == SOUND_BEE && source instanceof BeeEntity) {
soundManager.playNextTick(
@ -74,9 +74,9 @@ public class ClientInteractionManager extends InteractionManager {
soundManager.play(new LoopingSoundInstance<>((PlayerEntity)source, e -> {
PlayerPhysics physics = Pony.of(e).getPhysics();
return physics.isFlying() && physics.getFlightType() == FlightType.INSECTOID;
}, USounds.ENTITY_PLAYER_CHANGELING_BUZZ, 1F, 1F, Random.create(seed)));
}, USounds.ENTITY_PLAYER_CHANGELING_BUZZ, 1F, 1F, new Random(seed)));
} else if (type == SOUND_GLIDING && source instanceof PlayerEntity) {
soundManager.play(new MotionBasedSoundInstance(SoundEvents.ITEM_ELYTRA_FLYING, (PlayerEntity)source, Random.create(seed)));
soundManager.play(new MotionBasedSoundInstance(SoundEvents.ITEM_ELYTRA_FLYING, (PlayerEntity)source, new Random(seed)));
} else if (type == SOUND_MAGIC_BEAM) {
soundManager.play(new LoopedEntityTrackingSoundInstance(USounds.SPELL_CAST_SHOOT, 0.3F, 1F, source, seed));
}

View file

@ -13,12 +13,13 @@ import net.minecraft.client.toast.Toast;
import net.minecraft.client.toast.ToastManager;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
public class DiscoveryToast implements Toast {
private static final long MAX_AGE = 5000L;
private static final Text TITLE = Text.translatable("unicopia.toast.discoveries.title");
private static final Text DESCRIPTION = Text.translatable("unicopia.toast.discoveries.description");
private static final Text TITLE = new TranslatableText("unicopia.toast.discoveries.title");
private static final Text DESCRIPTION = new TranslatableText("unicopia.toast.discoveries.description");
private final List<Identifier> discoveries = new ArrayList<>();
private long startTime;

View file

@ -9,9 +9,9 @@ import net.minecraft.text.*;
public interface FlowingText {
static Stream<Text> wrap(Text text, int maxWidth) {
return MinecraftClient.getInstance().textRenderer.getTextHandler().wrapLines(text, maxWidth, Style.EMPTY).stream().map(line -> {
MutableText compiled = Text.literal("");
MutableText compiled = new LiteralText("");
line.visit((s, t) -> {
compiled.append(Text.literal(t).setStyle(s));
compiled.append(new LiteralText(t).setStyle(s));
return Optional.empty();
}, text.getStyle());
return compiled;

View file

@ -19,7 +19,7 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.text.*;
import net.minecraft.util.math.MathHelper;
public class KeyBindingsHandler {
@ -105,7 +105,7 @@ public class KeyBindingsHandler {
private void changePage(MinecraftClient client, long max, int sigma) {
page += sigma;
client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.75F + (0.25F * sigma)));
UHud.INSTANCE.setMessage(Text.translatable("gui.unicopia.page_num", page + 1, max + 1));
UHud.INSTANCE.setMessage(new TranslatableText("gui.unicopia.page_num", page + 1, max + 1));
}
public class Binding {

View file

@ -26,8 +26,7 @@ import net.minecraft.entity.attribute.EntityAttributeModifier.Operation;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import net.minecraft.text.*;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
@ -59,10 +58,10 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback {
.forEach(entry -> describeModifiers(entry.getKey(), entry.getValue(), null, newLines));
if (!newLines.isEmpty()) {
Text find = Text.translatable("item.modifiers." + slot.getName()).formatted(Formatting.GRAY);
Text find = new TranslatableText("item.modifiers." + slot.getName()).formatted(Formatting.GRAY);
int insertPosition = getInsertPosition(stack, find, flags, lines, context.isAdvanced());
if (insertPosition == -1) {
lines.add(ScreenTexts.EMPTY);
lines.add(LiteralText.EMPTY);
lines.add(find);
lines.addAll(newLines);
} else {
@ -86,23 +85,23 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback {
if (insertPosition == -1 && stack.hasNbt()) {
if (isShowing(flags, ItemStack.TooltipSection.MODIFIERS) && stack.getNbt().getBoolean("Unbreakable")) {
insertPosition = checkFor(lines, Text.translatable("item.unbreakable").formatted(Formatting.BLUE));
insertPosition = checkFor(lines, new TranslatableText("item.unbreakable").formatted(Formatting.BLUE));
}
if (insertPosition == -1 && isShowing(flags, ItemStack.TooltipSection.CAN_DESTROY) && stack.getNbt().contains("CanDestroy", 9)) {
insertPosition = checkFor(lines, Text.translatable("item.canBreak").formatted(Formatting.GRAY));
insertPosition = checkFor(lines, new TranslatableText("item.canBreak").formatted(Formatting.GRAY));
}
if (insertPosition == -1 && isShowing(flags, ItemStack.TooltipSection.CAN_PLACE) && stack.getNbt().contains("CanPlaceOn", 9)) {
insertPosition = checkFor(lines, Text.translatable("item.canPlace").formatted(Formatting.GRAY));
insertPosition = checkFor(lines, new TranslatableText("item.canPlace").formatted(Formatting.GRAY));
}
}
if (insertPosition == -1 && advanced) {
if (stack.isDamaged()) {
insertPosition = checkFor(lines, Text.translatable("item.durability", stack.getMaxDamage() - stack.getDamage(), stack.getMaxDamage()));
insertPosition = checkFor(lines, new TranslatableText("item.durability", stack.getMaxDamage() - stack.getDamage(), stack.getMaxDamage()));
} else {
insertPosition = checkFor(lines, Text.literal(Registry.ITEM.getId(stack.getItem()).toString()).formatted(Formatting.DARK_GRAY));
insertPosition = checkFor(lines, new LiteralText(Registry.ITEM.getId(stack.getItem()).toString()).formatted(Formatting.DARK_GRAY));
}
}
@ -131,7 +130,7 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback {
}
if (baseAdjusted) {
lines.add(Text.literal(" ").append(getModifierLineBase("equals", displayValue, op, attribute, Formatting.DARK_GREEN)));
lines.add(new LiteralText(" ").append(getModifierLineBase("equals", displayValue, op, attribute, Formatting.DARK_GREEN)));
} else if (value > 0) {
lines.add(getModifierLineBase("plus", displayValue, op, attribute, attribute == UEntityAttributes.ENTITY_GRAVTY_MODIFIER ? Formatting.RED : Formatting.BLUE));
} else if (value < 0) {
@ -140,9 +139,9 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback {
}
private Text getModifierLineBase(String root, double displayValue, Operation op, EntityAttribute attribute, Formatting color) {
return Text.translatable("attribute.modifier." + root + "." + op.getId(),
return new TranslatableText("attribute.modifier." + root + "." + op.getId(),
ItemStack.MODIFIER_FORMAT.format(displayValue),
Text.translatable(attribute.getTranslationKey())
new TranslatableText(attribute.getTranslationKey())
).formatted(color);
}

View file

@ -24,7 +24,7 @@ import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreens;
import net.minecraft.client.gui.screen.world.CreateWorldScreen;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
public class UnicopiaClient implements ClientModInitializer {
@ -83,7 +83,7 @@ public class UnicopiaClient implements ClientModInitializer {
if (screen instanceof OpenToLanScreen) {
buttons.addButton(new Button(screen.width / 2 - 155, 130, 150, 20))
.onClick(b -> MinecraftClient.getInstance().setScreen(new LanSettingsScreen(screen)))
.getStyle().setText(Text.translatable("unicopia.options.title"));
.getStyle().setText(new TranslatableText("unicopia.options.title"));
}
}

View file

@ -16,12 +16,11 @@ import net.minecraft.client.gui.*;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.*;
import net.minecraft.util.StringHelper;
import net.minecraft.util.math.*;
import net.minecraft.util.math.Vector4f;
public class DismissSpellScreen extends GameGui {
private final Pony pony = Pony.of(MinecraftClient.getInstance().player);
@ -30,7 +29,7 @@ public class DismissSpellScreen extends GameGui {
private int relativeMouseY;
public DismissSpellScreen() {
super(Text.translatable("gui.unicopia.dismiss_spell"));
super(new TranslatableText("gui.unicopia.dismiss_spell"));
}
@Override
@ -92,7 +91,7 @@ public class DismissSpellScreen extends GameGui {
matrices.push();
matrices.translate(0, 0, 300);
Text cancel = Text.literal("Press ESC to cancel");
Text cancel = new LiteralText("Press ESC to cancel");
getFont().drawWithShadow(matrices, cancel, (width - getFont().getWidth(cancel)) / 2, height - 30, 0xFFFFFFFF);
matrices.pop();
}
@ -185,18 +184,18 @@ public class DismissSpellScreen extends GameGui {
MutableText name = actualSpell.getType().getName().copy();
color = actualSpell.getType().getColor();
name.setStyle(name.getStyle().withColor(color == 0 ? 0xFFAAAAAA : color));
tooltip.add(Text.translatable("Spell Type: %s", name));
tooltip.add(new TranslatableText("Spell Type: %s", name));
actualSpell.getType().getTraits().appendTooltip(tooltip);
tooltip.add(ScreenTexts.EMPTY);
tooltip.add(Text.translatable("Affinity: %s", actualSpell.getAffinity().name()).formatted(actualSpell.getAffinity().getColor()));
tooltip.add(ScreenTexts.EMPTY);
tooltip.addAll(FlowingText.wrap(Text.translatable(actualSpell.getType().getTranslationKey() + ".lore").formatted(actualSpell.getAffinity().getColor()), 180).toList());
tooltip.add(LiteralText.EMPTY);
tooltip.add(new TranslatableText("Affinity: %s", actualSpell.getAffinity().name()).formatted(actualSpell.getAffinity().getColor()));
tooltip.add(LiteralText.EMPTY);
tooltip.addAll(FlowingText.wrap(new TranslatableText(actualSpell.getType().getTranslationKey() + ".lore").formatted(actualSpell.getAffinity().getColor()), 180).toList());
if (spell instanceof TimedSpell timed) {
tooltip.add(ScreenTexts.EMPTY);
tooltip.add(Text.translatable("Time Left: %s", StringHelper.formatTicks(timed.getTimer().getTicksRemaining())));
tooltip.add(LiteralText.EMPTY);
tooltip.add(new TranslatableText("Time Left: %s", StringHelper.formatTicks(timed.getTimer().getTicksRemaining())));
}
tooltip.add(ScreenTexts.EMPTY);
tooltip.add(Text.translatable("[Click to Discard]"));
tooltip.add(LiteralText.EMPTY);
tooltip.add(new TranslatableText("[Click to Discard]"));
renderTooltip(matrices, tooltip, 0, 0);
if (!lastMouseOver) {

View file

@ -71,7 +71,8 @@ public interface DrawableUtil {
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(matrix, x1, y1, 0).color(r, g, b, k).next();
bufferBuilder.vertex(matrix, x2, y2, 0).color(r, g, b, k).next();
BufferRenderer.drawWithShader(bufferBuilder.end());
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
}
@ -119,7 +120,8 @@ public interface DrawableUtil {
cylendricalVertex(bufferBuilder, model, innerRadius, angle + INCREMENT, r, g, b, k);
}
BufferRenderer.drawWithShader(bufferBuilder.end());
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderSystem.enableTexture();
}
@ -185,7 +187,8 @@ public interface DrawableUtil {
}
}
BufferRenderer.drawWithShader(bufferBuilder.end());
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderSystem.enableTexture();
}

View file

@ -73,7 +73,7 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp
@Override
public MutableText copy() {
return Text.empty();
return new LiteralText("");
}
public static void renderTraitIcon(Trait trait, float value, MatrixStack matrices, int xx, int yy) {
@ -104,16 +104,21 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp
@Override
public Style getStyle() {
return Text.empty().getStyle();
}
@Override
public TextContent getContent() {
return Text.empty().getContent();
return Style.EMPTY;
}
@Override
public List<Text> getSiblings() {
return new ArrayList<>();
}
@Override
public String asString() {
return "";
}
@Override
public MutableText shallowCopy() {
return copy();
}
}

View file

@ -21,7 +21,7 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
public class LanSettingsScreen extends GameGui {
@ -40,7 +40,7 @@ public class LanSettingsScreen extends GameGui {
private boolean forceHideWhitelist;
public LanSettingsScreen(Screen parent) {
super(Text.translatable("unicopia.options.title"), parent);
super(new TranslatableText("unicopia.options.title"), parent);
content.margin.setVertical(30);
content.getContentPadding().setHorizontal(10);
@ -103,7 +103,7 @@ public class LanSettingsScreen extends GameGui {
if (whitelistEnabled) {
content.addButton(new Label(LEFT, row += 20)).getStyle().setText(Text.translatable("unicopia.options.whitelist.details").formatted(Formatting.DARK_GREEN));
content.addButton(new Label(LEFT, row += 20)).getStyle().setText(new TranslatableText("unicopia.options.whitelist.details").formatted(Formatting.DARK_GREEN));
row += 20;
WHITELIST_GRID_PACKER.start();

View file

@ -18,7 +18,7 @@ public class ParagraphWrappingVisitor implements StyledVisitor<Object> {
private final TextHandler handler = font.getTextHandler();
private float currentLineCollectedLength = 0;
private MutableText currentLine = Text.empty();
private MutableText currentLine = new LiteralText("");
private boolean progressedNonEmpty;
private final Int2IntFunction widthSupplier;
@ -57,7 +57,7 @@ public class ParagraphWrappingVisitor implements StyledVisitor<Object> {
trimmedLength = lastSpace > 0 ? Math.min(lastSpace, trimmedLength) : trimmedLength;
}
Text fragment = Text.literal(s.substring(0, trimmedLength).trim()).setStyle(style);
Text fragment = new LiteralText(s.substring(0, trimmedLength).trim()).setStyle(style);
float grabbedWidth = handler.getWidth(fragment);
// advance if appending the next segment would cause an overflow
@ -100,7 +100,7 @@ public class ParagraphWrappingVisitor implements StyledVisitor<Object> {
lineConsumer.accept(currentLine, (++line) * font.fontHeight);
}
pageWidth = widthSupplier.applyAsInt((++line) * font.fontHeight);
currentLine = Text.empty();
currentLine = new LiteralText("");
currentLineCollectedLength = 0;
}

View file

@ -17,6 +17,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
public class SettingsScreen extends GameGui {
@ -28,7 +29,7 @@ public class SettingsScreen extends GameGui {
private Style mineLpStatus;
public SettingsScreen(Screen parent) {
super(Text.translatable("unicopia.options.title"), parent);
super(new TranslatableText("unicopia.options.title"), parent);
content.margin.setVertical(30);
content.getContentPadding().setHorizontal(10);
@ -73,7 +74,7 @@ public class SettingsScreen extends GameGui {
content.addButton(new Slider(LEFT, row += 25, 0, races.size(), races.indexOf(config.preferredRace.get())))
.onChange(races.createSetter(config.preferredRace::set))
.setTextFormat(v -> Text.translatable("unicopia.options.preferred_race", races.valueOf(v.getValue()).getDisplayName()));
.setTextFormat(v -> new TranslatableText("unicopia.options.preferred_race", races.valueOf(v.getValue()).getDisplayName()));
IntegratedServer server = client.getServer();
if (server != null) {
@ -84,7 +85,7 @@ public class SettingsScreen extends GameGui {
content.addButton(new Slider(LEFT, row += 20, 0, races.size(), races.indexOf(tribes.getDefaultRace())))
.onChange(races.createSetter(tribes::setDefaultRace))
.setTextFormat(v -> Text.translatable("unicopia.options.world.default_race", races.valueOf(v.getValue()).getDisplayName()))
.setTextFormat(v -> new TranslatableText("unicopia.options.world.default_race", races.valueOf(v.getValue()).getDisplayName()))
.setEnabled(client.isInSingleplayer());
}
}
@ -94,13 +95,13 @@ public class SettingsScreen extends GameGui {
if (hasMineLP) {
if (config.ignoreMineLP.get()) {
return Text.translatable("unicopia.options.ignore_mine_lp.undetected").formatted(Formatting.DARK_GREEN);
return new TranslatableText("unicopia.options.ignore_mine_lp.undetected").formatted(Formatting.DARK_GREEN);
}
return Text.translatable("unicopia.options.ignore_mine_lp.detected", MineLPDelegate.getInstance().getPlayerPonyRace().getDisplayName()).formatted(Formatting.GREEN);
return new TranslatableText("unicopia.options.ignore_mine_lp.detected", MineLPDelegate.getInstance().getPlayerPonyRace().getDisplayName()).formatted(Formatting.GREEN);
}
return Text.translatable("unicopia.options.ignore_mine_lp.missing").formatted(Formatting.RED);
return new TranslatableText("unicopia.options.ignore_mine_lp.missing").formatted(Formatting.RED);
}
@Override

View file

@ -10,7 +10,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
@ -47,7 +47,7 @@ public class TribeButton extends Button {
if (hovered && screenWidth > 0) {
Identifier id = Race.REGISTRY.getId(race);
drawCenteredText(matrices, getFont(), Text.translatable("gui.unicopia.tribe_selection.describe." + id.getNamespace() + "." + id.getPath()), screenWidth / 2, y + height, 0xFFFFFFFF);
drawCenteredText(matrices, getFont(), new TranslatableText("gui.unicopia.tribe_selection.describe." + id.getNamespace() + "." + id.getPath()), screenWidth / 2, y + height, 0xFFFFFFFF);
}
}

View file

@ -11,6 +11,7 @@ import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.*;
public class TribeConfirmationScreen extends GameGui implements HidesHud {
@ -19,7 +20,7 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud {
private final BooleanConsumer callback;
public TribeConfirmationScreen(BooleanConsumer callback, Race selection) {
super(Text.translatable("gui.unicopia.tribe_selection"));
super(new TranslatableText("gui.unicopia.tribe_selection"));
this.callback = callback;
this.selection = selection;
}
@ -33,10 +34,10 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud {
int top = (height - columnHeight) / 2;
addDrawableChild(new ButtonWidget(width / 2 + 5, top + columnHeight + padding, 100, 20, Text.translatable("Join Tribe"), b -> callback.accept(true)));
addDrawableChild(new ButtonWidget(width / 2 - 105, top + columnHeight + padding, 100, 20, Text.translatable("Go Back"), b -> callback.accept(false)));
addDrawableChild(new ButtonWidget(width / 2 + 5, top + columnHeight + padding, 100, 20, new TranslatableText("Join Tribe"), b -> callback.accept(true)));
addDrawableChild(new ButtonWidget(width / 2 - 105, top + columnHeight + padding, 100, 20, new TranslatableText("Go Back"), b -> callback.accept(false)));
addDrawable(new Label(width / 2, top - 30).setCentered()).getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.confirm", selection.getDisplayName().copy().formatted(Formatting.YELLOW)));
addDrawable(new Label(width / 2, top - 30).setCentered()).getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.confirm", selection.getDisplayName().copy().formatted(Formatting.YELLOW)));
addDrawable(new TribeButton((width - 70) / 2, top, 0, selection));
@ -46,7 +47,7 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud {
Text race = selection.getAltDisplayName().copy().formatted(Formatting.YELLOW);
addDrawable(new Label(left - 3, top += 10)).getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.confirm.goods", race).formatted(Formatting.YELLOW));
addDrawable(new Label(left - 3, top += 10)).getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.confirm.goods", race).formatted(Formatting.YELLOW));
top += 15;
@ -58,12 +59,12 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud {
String key = String.format("gui.unicopia.tribe_selection.confirm.goods.%d.%s.%s", i, id.getNamespace(), id.getPath());
if (Language.getInstance().hasTranslation(key)) {
TextBlock block = addDrawable(new TextBlock(left, top, maxWidth));
block.getStyle().setText(Text.translatable(key));
block.getStyle().setText(new TranslatableText(key));
top += block.getBounds().height;
}
}
addDrawable(new Label(left - 3, top += 5)).getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.confirm.bads", race).formatted(Formatting.YELLOW));
addDrawable(new Label(left - 3, top += 5)).getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.confirm.bads", race).formatted(Formatting.YELLOW));
top += 15;
@ -71,7 +72,7 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud {
String key = String.format("gui.unicopia.tribe_selection.confirm.bads.%d.%s.%s", i, id.getNamespace(), id.getPath());
if (Language.getInstance().hasTranslation(key)) {
TextBlock block = addDrawable(new TextBlock(left, top, maxWidth));
block.getStyle().setText(Text.translatable(key));
block.getStyle().setText(new TranslatableText(key));
top += block.getBounds().height;
}
}

View file

@ -12,7 +12,7 @@ import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.network.MsgRequestSpeciesChange;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
@ -24,7 +24,7 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
private boolean finished;
public TribeSelectionScreen(Set<Race> allowedRaces) {
super(Text.translatable("gui.unicopia.tribe_selection"));
super(new TranslatableText("gui.unicopia.tribe_selection"));
this.allowedRaces = allowedRaces;
}
@ -40,11 +40,11 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
top += height / 8;
TextBlock block = addDrawable(new TextBlock(left, top += 10, pageWidth));
block.getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.welcome.journey"));
block.getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.welcome.journey"));
top += block.getBounds().height;
block = addDrawable(new TextBlock(left, top += 7, pageWidth));
block.getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.welcome.choice"));
block.getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.welcome.choice"));
top += block.getBounds().height;
Race preference = UnicopiaClient.getPreferredRace();
@ -67,7 +67,7 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
top = height - 20;
if (!preference.isDefault()) {
addDrawable(new Label(width / 2, top).setCentered()).getStyle().setText(Text.translatable("gui.unicopia.tribe_selection.preference", preference.getDisplayName().copy().formatted(Formatting.YELLOW)));
addDrawable(new Label(width / 2, top).setCentered()).getStyle().setText(new TranslatableText("gui.unicopia.tribe_selection.preference", preference.getDisplayName().copy().formatted(Formatting.YELLOW)));
}
}

View file

@ -1,6 +1,7 @@
package com.minelittlepony.unicopia.client.gui;
import java.util.List;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
@ -35,7 +36,6 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Quaternion;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.random.Random;
public class UHud extends DrawableHelper {

View file

@ -13,12 +13,13 @@ import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.*;
public class DynamicContent implements Content {
private static final Text UNKNOWN = Text.of("???");
private static final Text UNKNOWN_LEVEL = Text.literal("Level: ???").formatted(Formatting.DARK_GREEN);
private static final Text UNKNOWN_LEVEL = new LiteralText("Level: ???").formatted(Formatting.DARK_GREEN);
private SpellbookState.PageState state = new SpellbookState.PageState();
private final List<Page> pages;
@ -96,7 +97,7 @@ public class DynamicContent implements Content {
return (bounds.width - 10) - elements.stream()
.filter(PageElement::isFloating)
.map(PageElement::bounds)
.filter(b -> b.containsY(yPosition))
.filter(b -> b.contains(b.left + b.width / 2, yPosition))
.mapToInt(b -> b.width)
.sum();
}
@ -105,7 +106,7 @@ public class DynamicContent implements Content {
return elements.stream()
.filter(p -> p.flow() == Flow.LEFT)
.map(PageElement::bounds)
.filter(b -> b.containsY(yPosition))
.filter(b -> b.contains(b.left + b.width / 2, yPosition))
.mapToInt(b -> b.width)
.sum();
}
@ -143,14 +144,14 @@ public class DynamicContent implements Content {
int headerColor = mouseY % 255;
DrawableUtil.drawScaledText(matrices, needsMoreXp ? UNKNOWN : title, bounds.left, bounds.top - 10, 1.3F, headerColor);
DrawableUtil.drawScaledText(matrices, level < 0 ? UNKNOWN_LEVEL : Text.literal("Level: " + (level + 1)).formatted(Formatting.DARK_GREEN), bounds.left, bounds.top - 10 + 12, 0.8F, headerColor);
DrawableUtil.drawScaledText(matrices, level < 0 ? UNKNOWN_LEVEL : new LiteralText("Level: " + (level + 1)).formatted(Formatting.DARK_GREEN), bounds.left, bounds.top - 10 + 12, 0.8F, headerColor);
matrices.push();
matrices.translate(bounds.left, bounds.top + 16, 0);
elements.stream().filter(PageElement::isFloating).forEach(element -> {
Bounds bounds = element.bounds();
matrices.push();
bounds.translate(matrices);
matrices.translate(bounds.left, bounds.top, 0);
element.draw(matrices, mouseX, mouseY, container);
matrices.pop();
});

View file

@ -101,7 +101,7 @@ interface PageElement extends Drawable {
boolean needsMoreXp = page.getLevel() < 0 || Pony.of(MinecraftClient.getInstance().player).getLevel().get() < page.getLevel();
matrices.push();
wrappedText.forEach(line -> {
font.draw(matrices, needsMoreXp ? line.text().copy().formatted(Formatting.OBFUSCATED) : line.text().copy(), line.x(), 0, 0);
font.draw(matrices, needsMoreXp ? line.text().shallowCopy().formatted(Formatting.OBFUSCATED, Formatting.BLACK) : line.text(), line.x(), 0, 0xFF000000);
matrices.translate(0, font.fontHeight, 0);
});
matrices.pop();

View file

@ -5,16 +5,16 @@ import java.util.List;
import com.minelittlepony.common.client.gui.Tooltip;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.text.Text;
import net.minecraft.text.LiteralText;
public class ProfileTooltip {
public static Tooltip get(Pony pony) {
return () -> {
return List.of(
Text.literal(String.format("Level %d ", pony.getLevel().get() + 1)).append(pony.getSpecies().getDisplayName()).formatted(pony.getSpecies().getAffinity().getColor()),
Text.literal(String.format("Mana: %d%%", (int)(pony.getMagicalReserves().getMana().getPercentFill() * 100))),
Text.literal(String.format("Experience: %d", (int)(pony.getMagicalReserves().getXp().getPercentFill() * 100))),
Text.literal(String.format("Next level in: %d experience points", 100 - (int)(pony.getMagicalReserves().getXp().getPercentFill() * 100)))
new LiteralText(String.format("Level %d ", pony.getLevel().get() + 1)).append(pony.getSpecies().getDisplayName()).formatted(pony.getSpecies().getAffinity().getColor()),
new LiteralText(String.format("Mana: %d%%", (int)(pony.getMagicalReserves().getMana().getPercentFill() * 100))),
new LiteralText(String.format("Experience: %d", (int)(pony.getMagicalReserves().getXp().getPercentFill() * 100))),
new LiteralText(String.format("Next level in: %d experience points", 100 - (int)(pony.getMagicalReserves().getXp().getPercentFill() * 100)))
);
};
}

View file

@ -11,11 +11,12 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
public class SpellbookCraftingPageContent extends ScrollContainer implements SpellbookChapterList.Content, SpellbookScreen.RecipesChangedListener {
public static final Text INVENTORY_TITLE = Text.translatable("gui.unicopia.spellbook.page.inventory");
public static final Text RECIPES_TITLE = Text.translatable("gui.unicopia.spellbook.page.recipes");
public static final Text INVENTORY_TITLE = new TranslatableText("gui.unicopia.spellbook.page.inventory");
public static final Text RECIPES_TITLE = new TranslatableText("gui.unicopia.spellbook.page.recipes");
public static final int TOTAL_PAGES = 2;
private final SpellbookScreen screen;
@ -46,7 +47,7 @@ public class SpellbookCraftingPageContent extends ScrollContainer implements Spe
DrawableUtil.drawScaledText(matrices, state.getOffset() == 0 ? INVENTORY_TITLE : RECIPES_TITLE, screen.getFrameBounds().left + screen.getFrameBounds().width / 2 + 20, SpellbookScreen.TITLE_Y, 1.3F, headerColor);
Text pageText = Text.translatable("%s/%s", state.getOffset() + 1, TOTAL_PAGES);
Text pageText = new TranslatableText("%s/%s", state.getOffset() + 1, TOTAL_PAGES);
textRenderer.draw(matrices, pageText, 337 - textRenderer.getWidth(pageText) / 2F, 190, headerColor);
}

View file

@ -10,7 +10,7 @@ import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.text.*;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
@ -104,7 +104,7 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell
font.draw(matrices, "Mana", -font.getWidth("Mana") / 2, y, SpellbookScreen.TITLE_COLOR);
font.draw(matrices, manaString, -font.getWidth(manaString) / 2, y += font.fontHeight, SpellbookScreen.TITLE_COLOR);
Text levelString = I18n.hasTranslation("enchantment.level." + (currentLevel + 1)) ? Text.translatable("enchantment.level." + (currentLevel + 1)) : Text.literal(currentLevel >= 999 ? ">999" : "" + (currentLevel + 1));
Text levelString = I18n.hasTranslation("enchantment.level." + (currentLevel + 1)) ? new TranslatableText("enchantment.level." + (currentLevel + 1)) : new LiteralText(currentLevel >= 999 ? ">999" : "" + (currentLevel + 1));
matrices.translate(-font.getWidth(levelString), -35, 0);
matrices.scale(2F, 2F, 1);

View file

@ -202,6 +202,10 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> imple
protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) {
}
public void clearAndInit() {
init(client, width, height);
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
return tabs.getAllTabs().anyMatch(tab -> {
@ -244,6 +248,7 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> imple
getStyle().setIcon(sprite);
onClick(sender -> {
pageAction.accept(increment);
screen.init();
screen.clearAndInit();
});
}

View file

@ -20,7 +20,7 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.*;
import net.minecraft.text.Text;
import net.minecraft.text.*;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.collection.DefaultedList;
@ -104,9 +104,9 @@ public class SpellbookTraitDexPageContent extends DrawableHelper implements Spel
addButton(new TraitButton(width / 2 - 8, 8, trait));
addButton(new Label(width / 2, 26).setCentered())
.getStyle()
.setText(known ? Text.translatable("gui.unicopia.trait.label",
Text.translatable("trait." + trait.getId().getNamespace() + "." + trait.getId().getPath() + ".name")
) : Text.literal("???"));
.setText(known ? new TranslatableText("gui.unicopia.trait.label",
new TranslatableText("trait." + trait.getId().getNamespace() + "." + trait.getId().getPath() + ".name")
) : new LiteralText("???"));
IngredientTree tree = new IngredientTree(0, 50, width + 18).noLabels();
List<Item> knownItems = Pony.of(MinecraftClient.getInstance().player).getDiscoveries().getKnownItems(trait).toList();

View file

@ -58,9 +58,9 @@ public class LightningBoltParticle extends AbstractGeometryBasedParticle {
while (nodes.size() < intendedLength) {
startPos = startPos.add(
world.random.nextTriangular(0.1, 3),
world.random.nextTriangular(0.1, 3),
world.random.nextTriangular(0.1, 3)
0.1 + world.random.nextDouble(6) - 3,
0.1 + world.random.nextDouble(6) - 3,
0.1 + world.random.nextDouble(6) - 3
);
nodes.add(startPos);

View file

@ -23,6 +23,6 @@ public class IcarusWingsFeatureRenderer<E extends LivingEntity> extends WingsFea
@Override
protected Identifier getTexture(E entity) {
return entity.world.getDimension().ultrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS;
return entity.world.getDimension().isUltrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS;
}
}

View file

@ -1,11 +1,12 @@
package com.minelittlepony.unicopia.client.sound;
import java.util.Random;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.sound.MovingSoundInstance;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.random.Random;
public abstract class FadeOutSoundInstance extends MovingSoundInstance {
@ -21,7 +22,7 @@ public abstract class FadeOutSoundInstance extends MovingSoundInstance {
private boolean fadingOut;
public FadeOutSoundInstance(SoundEvent sound, SoundCategory category, float volume, Random random) {
super(sound, category, random);
super(sound, category);
this.relative = true;
this.repeat = true;
this.volume = volume;
@ -72,6 +73,6 @@ public abstract class FadeOutSoundInstance extends MovingSoundInstance {
@Override
public final float getVolume() {
return getLerpedVolume() * sound.getVolume().get(field_38800);
return getLerpedVolume() * sound.getVolume();
}
}

View file

@ -6,7 +6,7 @@ import net.minecraft.sound.SoundEvent;
public class LoopedEntityTrackingSoundInstance extends EntityTrackingSoundInstance {
public LoopedEntityTrackingSoundInstance(SoundEvent soundEvent, float volume, float pitch, Entity entity, long seed) {
super(soundEvent, entity.getSoundCategory(), volume, pitch, entity, seed);
super(soundEvent, entity.getSoundCategory(), volume, pitch, entity);
this.repeat = true;
this.repeatDelay = 0;
}

View file

@ -1,11 +1,11 @@
package com.minelittlepony.unicopia.client.sound;
import java.util.Random;
import java.util.function.Predicate;
import net.minecraft.client.sound.SoundInstance;
import net.minecraft.entity.Entity;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.math.random.Random;
public class LoopingSoundInstance<T extends Entity> extends FadeOutSoundInstance {

View file

@ -1,6 +1,7 @@
package com.minelittlepony.unicopia.client.sound;
import java.util.Optional;
import java.util.Random;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.entity.Living;
@ -9,7 +10,6 @@ import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
public class MagicAuraSoundInstance extends FadeOutSoundInstance {

View file

@ -1,11 +1,12 @@
package com.minelittlepony.unicopia.client.sound;
import java.util.Random;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.random.Random;
public class MotionBasedSoundInstance extends FadeOutSoundInstance {

View file

@ -1,22 +1,20 @@
package com.minelittlepony.unicopia.command;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import com.minelittlepony.unicopia.Unicopia;
import net.fabricmc.fabric.api.command.v2.ArgumentTypeRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.command.argument.ArgumentTypes;
import net.minecraft.server.MinecraftServer;
public class Commands {
@SuppressWarnings({ "deprecation", "unchecked", "rawtypes" })
public static void bootstrap() {
ArgumentTypeRegistry.registerArgumentType(
Unicopia.id("enumeration"),
ArgumentTypes.register(
"unicopia:enumeration",
EnumArgumentType.class,
new EnumArgumentType.Serializer()
);
CommandRegistrationCallback.EVENT.register((dispatcher, access, environment) -> {
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
SpeciesCommand.register(dispatcher);
RacelistCommand.register(dispatcher);
GravityCommand.register(dispatcher);

View file

@ -26,12 +26,12 @@ import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.world.GameRules;
public class DisguiseCommand {
private static final SimpleCommandExceptionType FAILED_EXCEPTION = new SimpleCommandExceptionType(Text.translatable("commands.disguise.notfound"));
private static final SimpleCommandExceptionType FAILED_EXCEPTION = new SimpleCommandExceptionType(new TranslatableText("commands.disguise.notfound"));
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(CommandManager
@ -87,13 +87,13 @@ public class DisguiseCommand {
.setDisguise(entity);
if (source.getEntity() == player) {
source.sendFeedback(Text.translatable("commands.disguise.success.self", entity.getName()), true);
source.sendFeedback(new TranslatableText("commands.disguise.success.self", entity.getName()), true);
} else {
if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(Text.translatable("commands.disguise.success", entity.getName()));
player.sendMessage(new TranslatableText("commands.disguise.success", entity.getName()), false);
}
source.sendFeedback(Text.translatable("commands.disguise.success.other", player.getName(), entity.getName()), true);
source.sendFeedback(new TranslatableText("commands.disguise.success.other", player.getName(), entity.getName()), true);
}
return 0;
@ -114,13 +114,13 @@ public class DisguiseCommand {
iplayer.getSpellSlot().removeIf(SpellPredicate.IS_DISGUISE, true);
if (source.getEntity() == player) {
source.sendFeedback(Text.translatable("commands.disguise.removed.self"), true);
source.sendFeedback(new TranslatableText("commands.disguise.removed.self"), true);
} else {
if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(Text.translatable("commands.disguise.removed"));
player.sendMessage(new TranslatableText("commands.disguise.removed"), false);
}
source.sendFeedback(Text.translatable("commands.disguise.removed.other", player.getName()), true);
source.sendFeedback(new TranslatableText("commands.disguise.removed.other", player.getName()), true);
}
return 0;

View file

@ -20,9 +20,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.command.argument.serialize.ArgumentSerializer;
import net.minecraft.command.argument.serialize.ArgumentSerializer.ArgumentTypeProperties;
import net.minecraft.network.PacketByteBuf;
class EnumArgumentType<T extends Enum<T>> implements ArgumentType<T>, Serializable {
@ -95,52 +93,28 @@ class EnumArgumentType<T extends Enum<T>> implements ArgumentType<T>, Serializab
return suggestions;
}
public static class Serializer<T extends Enum<T>> implements ArgumentSerializer<EnumArgumentType<T>, Serializer<T>.Properties> {
public static class Serializer<T extends Enum<T>> implements ArgumentSerializer<EnumArgumentType<T>> {
@SuppressWarnings("unchecked")
@Override
public Properties fromPacket(PacketByteBuf buf) {
public EnumArgumentType<T> fromPacket(PacketByteBuf buf) {
try (ObjectInputStream stream = new ObjectInputStream(new ByteBufInputStream(buf))) {
return getArgumentTypeProperties((EnumArgumentType<T>)stream.readObject());
return (EnumArgumentType<T>)stream.readObject();
} catch (IOException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@Override
public void writePacket(Properties properties, PacketByteBuf buf) {
public void toPacket(EnumArgumentType<T> type, PacketByteBuf buf) {
try (ObjectOutputStream stream = new ObjectOutputStream(new ByteBufOutputStream(buf))) {
stream.writeObject(properties.type);
stream.writeObject(type);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
public void writeJson(Properties properties, JsonObject json) {
}
@Override
public Properties getArgumentTypeProperties(EnumArgumentType<T> type) {
return new Properties(type);
}
public final class Properties implements ArgumentTypeProperties<EnumArgumentType<T>> {
private final EnumArgumentType<T> type;
public Properties(EnumArgumentType<T> type) {
this.type = type;
}
@Override
public EnumArgumentType<T> createType(CommandRegistryAccess var1) {
return type;
}
@Override
public ArgumentSerializer<EnumArgumentType<T>, ?> getSerializer() {
return Serializer.this;
}
public void toJson(EnumArgumentType<T> var1, JsonObject var2) {
}
}
}

View file

@ -10,7 +10,7 @@ import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.world.GameRules;
class GravityCommand {
@ -43,9 +43,9 @@ class GravityCommand {
float gravity = iplayer.getPhysics().getGravityModifier();
if (source.getPlayer() == player) {
player.sendMessage(Text.translatable(translationKey, gravity), false);
player.sendMessage(new TranslatableText(translationKey, gravity), false);
} else {
source.sendFeedback(Text.translatable(translationKey + ".other", player.getName(), gravity), true);
source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true);
}
return 0;
@ -60,13 +60,13 @@ class GravityCommand {
iplayer.setDirty();
if (source.getEntity() == player) {
source.sendFeedback(Text.translatable("commands.gamemode.success.self", gravity), true);
source.sendFeedback(new TranslatableText("commands.gamemode.success.self", gravity), true);
} else {
if (source.getWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(Text.translatable(translationKey, gravity));
player.sendMessage(new TranslatableText(translationKey, gravity), false);
}
source.sendFeedback(Text.translatable(translationKey + ".other", player.getName(), gravity), true);
source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true);
}
return 0;

View file

@ -8,7 +8,7 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.FloatArgumentType;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.text.LiteralText;
public class ManaCommand {
static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
@ -19,7 +19,7 @@ public class ManaCommand {
var pony = Pony.of(source.getSource().getPlayer());
var bar = type.getBar(pony.getMagicalReserves());
source.getSource().getPlayer().sendMessage(Text.literal(type.name() + " is " + bar.get() + "/" + bar.getMax()));
source.getSource().getPlayer().sendMessage(new LiteralText(type.name() + " is " + bar.get() + "/" + bar.getMax()), false);
return 0;
})
.then(CommandManager.argument("value", FloatArgumentType.floatArg()).executes(source -> {
@ -28,7 +28,7 @@ public class ManaCommand {
var bar = type.getBar(pony.getMagicalReserves());
bar.set(source.getArgument("value", Float.class));
source.getSource().getPlayer().sendMessage(Text.literal("Set " + type.name() + " to " + bar.get() + "/" + bar.getMax()));
source.getSource().getPlayer().sendMessage(new LiteralText("Set " + type.name() + " to " + bar.get() + "/" + bar.getMax()), false);
return 0;
}))
)

View file

@ -12,6 +12,7 @@ import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
class RacelistCommand {
@ -54,7 +55,7 @@ class RacelistCommand {
Text formattedName = race.getDisplayName().copy().formatted(Formatting.GOLD);
source.sendFeedback(Text.translatable(translationKey, formattedName).formatted(Formatting.GREEN), false);
source.sendFeedback(new TranslatableText(translationKey, formattedName).formatted(Formatting.GREEN), false);
return 0;
}
}

View file

@ -10,8 +10,7 @@ import net.minecraft.command.argument.RegistryKeyArgumentType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.*;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.world.GameRules;
@ -55,15 +54,15 @@ class SpeciesCommand {
pony.setDirty();
if (!isSelf) {
source.sendFeedback(Text.translatable("commands.race.success.other", player.getName(), race.getDisplayName()), true);
source.sendFeedback(new TranslatableText("commands.race.success.other", player.getName(), race.getDisplayName()), true);
} else {
if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(Text.translatable("commands.race.success.self"), false);
player.sendMessage(new TranslatableText("commands.race.success.self"), false);
}
source.sendFeedback(Text.translatable("commands.race.success.otherself", player.getName(), race.getDisplayName()), true);
source.sendFeedback(new TranslatableText("commands.race.success.otherself", player.getName(), race.getDisplayName()), true);
}
} else if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(Text.translatable("commands.race.permission"), false);
player.sendMessage(new TranslatableText("commands.race.permission"), false);
}
return 0;
@ -75,22 +74,22 @@ class SpeciesCommand {
String name = "commands.race.tell.";
name += isSelf ? "self" : "other";
player.sendMessage(Text.translatable(name)
.append(Text.translatable(spec.getTranslationKey())
player.sendMessage(new TranslatableText(name)
.append(new TranslatableText(spec.getTranslationKey())
.styled(s -> s.withColor(Formatting.GOLD))), false);
return 0;
}
static int list(PlayerEntity player) {
player.sendMessage(Text.translatable("commands.race.list"), false);
player.sendMessage(new TranslatableText("commands.race.list"), false);
MutableText message = Text.literal("");
MutableText message = new LiteralText("");
boolean first = true;
for (Race i : Race.REGISTRY) {
if (!i.isDefault() && i.isPermitted(player)) {
message.append(Text.literal((!first ? "\n" : "") + " - "));
message.append(new LiteralText((!first ? "\n" : "") + " - "));
message.append(i.getDisplayName());
first = false;
}
@ -104,9 +103,9 @@ class SpeciesCommand {
static int describe(PlayerEntity player, Race species) {
Identifier id = Race.REGISTRY.getId(species);
player.sendMessage(Text.translatable(String.format("commands.race.describe.%s.%s.1", id.getNamespace(), id.getPath())).styled(s -> s.withColor(Formatting.YELLOW)), false);
player.sendMessage(Text.translatable(String.format("commands.race.describe.%s.%s.2", id.getNamespace(), id.getPath())), false);
player.sendMessage(Text.translatable(String.format("commands.race.describe.%s.%s.3", id.getNamespace(), id.getPath())).styled(s -> s.withColor(Formatting.RED)), false);
player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.%s.1", id.getNamespace(), id.getPath())).styled(s -> s.withColor(Formatting.YELLOW)), false);
player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.%s.2", id.getNamespace(), id.getPath())), false);
player.sendMessage(new TranslatableText(String.format("commands.race.describe.%s.%s.3", id.getNamespace(), id.getPath())).styled(s -> s.withColor(Formatting.RED)), false);
return 0;
}

View file

@ -43,13 +43,13 @@ class TraitCommand {
static int add(ServerCommandSource source, PlayerEntity player, Trait trait, float amount) throws CommandSyntaxException {
if (trait == null) {
source.sendError(Text.literal("Invalid trait"));
source.sendError(new LiteralText("Invalid trait"));
return 0;
}
ItemStack stack = player.getMainHandStack();
if (stack.isEmpty()) {
source.sendError(Text.literal("That trait cannot be added to the current item"));
source.sendError(new LiteralText("That trait cannot be added to the current item"));
return 0;
}
@ -60,7 +60,7 @@ class TraitCommand {
static int remove(ServerCommandSource source, PlayerEntity player, Trait trait) throws CommandSyntaxException {
if (trait == null) {
source.sendError(Text.literal("Invalid trait"));
source.sendError(new LiteralText("Invalid trait"));
return 0;
}
@ -84,9 +84,9 @@ class TraitCommand {
float gravity = iplayer.getPhysics().getGravityModifier();
if (source.getPlayer() == player) {
player.sendMessage(Text.translatable(translationKey, gravity), false);
player.sendMessage(new TranslatableText(translationKey, gravity), false);
} else {
source.sendFeedback(Text.translatable(translationKey + ".other", player.getName(), gravity), true);
source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true);
}
return 0;

View file

@ -1,7 +1,6 @@
package com.minelittlepony.unicopia.container;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
@ -29,7 +28,7 @@ import net.minecraft.util.profiler.Profiler;
public class SpellbookChapterLoader extends JsonDataLoader implements IdentifiableResourceReloadListener {
private static final Logger LOGGER = LogUtils.getLogger();
private static final Identifier ID = Unicopia.id("spellbook/chapters");
private static final Executor EXECUTOR = CompletableFuture.delayedExecutor(5, TimeUnit.SECONDS);
//private static final Executor EXECUTOR = CompletableFuture.delayedExecutor(5, TimeUnit.SECONDS);
public static boolean DEBUG = false;
public static final SpellbookChapterLoader INSTANCE = new SpellbookChapterLoader();
@ -73,7 +72,7 @@ public class SpellbookChapterLoader extends JsonDataLoader implements Identifiab
LOGGER.error("Could not load spellbook chapters due to exception", e);
}
if (DEBUG) {
/*if (DEBUG) {
CompletableFuture.runAsync(() -> {
try {
Util.waitAndApply(executor -> reload(CompletableFuture::completedFuture, manager, profiler, profiler, Util.getMainWorkerExecutor(), executor)).get();
@ -81,7 +80,7 @@ public class SpellbookChapterLoader extends JsonDataLoader implements Identifiab
}
dirty = true;
}, EXECUTOR);
}
}*/
}
public record Chapter (

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.container;
import com.minelittlepony.unicopia.Unicopia;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType;
import net.fabricmc.fabric.impl.screenhandler.ExtendedScreenHandlerType;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.util.registry.Registry;

View file

@ -1,8 +1,6 @@
package com.minelittlepony.unicopia.entity;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import org.jetbrains.annotations.Nullable;
@ -31,7 +29,6 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;

View file

@ -20,6 +20,7 @@ import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.Packet;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.world.World;
public class CastSpellEntity extends LightEmittingEntity implements Caster<LivingEntity>, WeaklyOwned<LivingEntity> {
@ -53,7 +54,7 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster<Livin
public Text getName() {
Entity master = getMaster();
if (master != null) {
return Text.translatable("entity.unicopia.cast_spell.by", master.getName());
return new TranslatableText("entity.unicopia.cast_spell.by", master.getName());
}
return super.getName();
}

View file

@ -180,7 +180,7 @@ public class FloatingArtefactEntity extends Entity {
}
@Override
public boolean canHit() {
public boolean collides() {
return true;
}

View file

@ -1,6 +1,7 @@
package com.minelittlepony.unicopia.entity;
import java.util.List;
import java.util.Random;
import org.jetbrains.annotations.NotNull;
@ -26,7 +27,6 @@ import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
public class ItemImpl implements Equine<ItemEntity>, Owned<ItemEntity> {
private static final TrackedData<String> ITEM_RACE = DataTracker.registerData(ItemEntity.class, TrackedDataHandlerRegistry.STRING);

View file

@ -124,7 +124,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
DragonBreathStore store = DragonBreathStore.get(entity.world);
String name = entity.getDisplayName().getString();
store.popEntries(name).forEach(stack -> {
Vec3d randomPos = targetPos.add(VecHelper.supply(() -> entity.getRandom().nextTriangular(0.1, 0.5)));
Vec3d randomPos = targetPos.add(VecHelper.supply(() -> 0.1 + entity.getRandom().nextDouble(1) - 0.5));
if (!entity.getWorld().isAir(new BlockPos(randomPos))) {
store.put(name, stack.payload());
@ -132,7 +132,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
for (int i = 0; i < 10; i++) {
ParticleUtils.spawnParticle(entity.world, ParticleTypes.FLAME, randomPos.add(
VecHelper.supply(() -> entity.getRandom().nextTriangular(0.1, 0.5))
VecHelper.supply(() -> 0.1 + entity.getRandom().nextDouble(1) - 0.5)
), Vec3d.ZERO);
}

View file

@ -1,5 +1,7 @@
package com.minelittlepony.unicopia.entity;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.UTags;
@ -16,7 +18,6 @@ import net.minecraft.item.Items;
import net.minecraft.tag.ItemTags;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Util;
import net.minecraft.util.math.random.Random;
import net.minecraft.village.TradeOffer;
import net.minecraft.village.TradeOffers;
import net.minecraft.village.VillagerProfession;

View file

@ -113,7 +113,7 @@ public interface Disguise extends FlightType.Provider, PlayerDimensions.Provider
}
static abstract class PlayerAccess extends PlayerEntity {
public PlayerAccess() { super(null, null, 0, null, null); }
public PlayerAccess() { super(null, null, 0, null); }
static TrackedData<Byte> getModelBitFlag() {
return PLAYER_MODEL_PARTS;
}

View file

@ -1,5 +1,7 @@
package com.minelittlepony.unicopia.entity.behaviour;
import java.util.Random;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.mixin.MixinSheepEntity;
@ -12,7 +14,6 @@ import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.WorldEvents;
public class SheepBehaviour extends EntityBehaviour<SheepEntity> {

View file

@ -4,7 +4,7 @@ import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.entity.passive.*;
public class SteedBehaviour<T extends AbstractHorseEntity> extends EntityBehaviour<T> {
public class SteedBehaviour<T extends HorseBaseEntity> extends EntityBehaviour<T> {
@Override
public void update(Pony player, T horse, Disguise spell) {

View file

@ -15,6 +15,7 @@ import net.minecraft.entity.effect.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
@ -150,7 +151,7 @@ public class RaceChangeStatusEffect extends StatusEffect {
}
public Text getMessage(Race race) {
return Text.translatable(getTranslationKey(), race.getDisplayName());
return new TranslatableText(getTranslationKey(), race.getDisplayName());
}
}
}

View file

@ -51,7 +51,7 @@ public class SunBlindnessStatusEffect extends StatusEffect {
public static boolean hasSunExposure(LivingEntity entity) {
if (entity.hasPortalCooldown()) {
if (entity.hasNetherPortalCooldown()) {
return false;
}

View file

@ -70,7 +70,7 @@ public class PlayerCharmTracker implements Tickable, NbtSerialisable {
}
public TypedActionResult<CustomisedSpellType<?>> getSpellInHand(Hand hand) {
return Streams.stream(pony.getMaster().getHandItems())
return Streams.stream(pony.getMaster().getItemsHand())
.filter(GemstoneItem::isEnchanted)
.map(stack -> GemstoneItem.consumeSpell(stack, pony.getMaster(), null))
.findFirst()

View file

@ -192,7 +192,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
if (typeChanged) {
pony.spawnParticles(ParticleTypes.CLOUD, 10);
entity.playSound(entity.world.getDimension().ultrawarm() ? USounds.ITEM_ICARUS_WINGS_CORRUPT : USounds.ITEM_ICARUS_WINGS_PURIFY, 0.1125F, 1.5F);
entity.playSound(entity.world.getDimension().isUltrawarm() ? USounds.ITEM_ICARUS_WINGS_CORRUPT : USounds.ITEM_ICARUS_WINGS_PURIFY, 0.1125F, 1.5F);
}
entity.getAbilities().allowFlying = type.canFlyCreative(entity);
@ -369,7 +369,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
if (entity.world.hasRain(entity.getBlockPos())) {
energyConsumed *= 3;
}
if (entity.world.getDimension().ultrawarm()) {
if (entity.world.getDimension().isUltrawarm()) {
energyConsumed *= 4;
damageInterval /= 2;
minDamage *= 3;

View file

@ -58,6 +58,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Hand;
import net.minecraft.util.math.*;
@ -369,7 +370,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
ticksHanging = 0;
}
if (getSpecies() == Race.BAT && !entity.hasPortalCooldown()) {
if (getSpecies() == Race.BAT && !entity.hasNetherPortalCooldown()) {
if (SunBlindnessStatusEffect.hasSunExposure(entity)) {
if (ticksInSun < 200) {
ticksInSun++;
@ -448,7 +449,6 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
return Optional.empty();
}
@SuppressWarnings("deprecation")
@Override
protected void handleFall(float distance, float damageMultiplier, DamageSource cause) {
super.handleFall(distance, damageMultiplier, cause);
@ -529,13 +529,13 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
public Optional<Text> trySleep(BlockPos pos) {
if (UItems.ALICORN_AMULET.isApplicable(entity)) {
return Optional.of(Text.translatable("block.unicopia.bed.not_tired"));
return Optional.of(new TranslatableText("block.unicopia.bed.not_tired"));
}
return findAllSpellsInRange(10)
.filter(p -> p instanceof Pony && ((Pony)p).isEnemy(this))
.findFirst()
.map(p -> Text.translatable("block.unicopia.bed.not_safe"));
.map(p -> new TranslatableText("block.unicopia.bed.not_safe"));
}
@Override

View file

@ -17,7 +17,7 @@ import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
import net.minecraft.text.Text;
import net.minecraft.text.LiteralText;
import net.minecraft.world.GameMode;
public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implements Owned<PlayerEntity> {
@ -27,7 +27,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen
private PlayerEntity owner;
public DummyClientPlayerEntity(ClientWorld world, GameProfile profile) {
super(world, profile, null);
super(world, profile);
}
@Override
@ -49,7 +49,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen
playerInfo = connection.getPlayerListEntry(getGameProfile().getId());
if (playerInfo == null) {
playerInfo = new PlayerListEntry(new Packet().entry(), MinecraftClient.getInstance().getServicesSignatureVerifier(), false);
playerInfo = new PlayerListEntry(new Packet().entry());
}
}
@ -57,7 +57,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen
}
@Override
protected void playEquipSound(ItemStack stack) {
protected void onEquipStack(ItemStack stack) {
/*noop*/
}
@ -87,7 +87,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen
getGameProfile(),
0,
GameMode.DEFAULT,
Text.literal(getGameProfile().getName()), null);
new LiteralText(getGameProfile().getName()));
}
}
}

View file

@ -16,11 +16,11 @@ public class DummyPlayerEntity extends PlayerEntity implements Owned<PlayerEntit
private PlayerEntity owner;
public DummyPlayerEntity(World world, GameProfile profile) {
super(world, BlockPos.ORIGIN, 0, profile, null);
super(world, BlockPos.ORIGIN, 0, profile);
}
@Override
protected void playEquipSound(ItemStack stack) {
protected void onEquipStack(ItemStack stack) {
/*noop*/
}

View file

@ -17,11 +17,11 @@ public class DummyServerPlayerEntity extends ServerPlayerEntity implements Owned
private PlayerEntity owner;
public DummyServerPlayerEntity(ServerWorld world, GameProfile profile) {
super(world.getServer(), world, profile, null);
super(world.getServer(), world, profile);
}
@Override
protected void playEquipSound(ItemStack stack) {
protected void onEquipStack(ItemStack stack) {
/*noop*/
}

View file

@ -36,6 +36,7 @@ import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.StringHelper;
@ -70,7 +71,7 @@ public class AlicornAmuletItem extends AmuletItem implements PlayerCharmTracker.
if (iplayer != null) {
int attachedTime = iplayer.getCharms().getArmour().getTicks(this);
if (attachedTime > 0) {
tooltip.add(Text.translatable(getTranslationKey() + ".lore", StringHelper.formatTicks(attachedTime)));
tooltip.add(new TranslatableText(getTranslationKey() + ".lore", StringHelper.formatTicks(attachedTime)));
}
}
}

View file

@ -23,10 +23,7 @@ import net.minecraft.item.ArmorMaterials;
import net.minecraft.item.ItemStack;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundEvent;
import net.minecraft.text.MutableText;
import net.minecraft.text.StringVisitable;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.text.*;
import net.minecraft.util.Formatting;
import net.minecraft.world.World;
@ -53,7 +50,7 @@ public class AmuletItem extends WearableItem {
&& entity instanceof LivingEntity
&& ((LivingEntity) entity).getEquippedStack(EquipmentSlot.CHEST) == stack
&& isApplicable((LivingEntity)entity)) {
ParticleUtils.spawnParticles(entity.world.getDimension().ultrawarm() ? ParticleTypes.SOUL_FIRE_FLAME : ParticleTypes.COMPOSTER, entity, 1);
ParticleUtils.spawnParticles(entity.world.getDimension().isUltrawarm() ? ParticleTypes.SOUL_FIRE_FLAME : ParticleTypes.COMPOSTER, entity, 1);
}
}
@ -61,8 +58,8 @@ public class AmuletItem extends WearableItem {
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> list, TooltipContext tooltipContext) {
for (StringVisitable line : MinecraftClient.getInstance().textRenderer.getTextHandler().wrapLines(
Text.translatable(getTranslationKey(stack) + ".lore"), 150, Style.EMPTY)) {
MutableText compiled = Text.literal("").formatted(Formatting.ITALIC, Formatting.GRAY);
new TranslatableText(getTranslationKey(stack) + ".lore"), 150, Style.EMPTY)) {
MutableText compiled = new LiteralText("").formatted(Formatting.ITALIC, Formatting.GRAY);
line.visit(s -> {
compiled.append(s);
return Optional.empty();
@ -71,7 +68,7 @@ public class AmuletItem extends WearableItem {
}
if (isChargable()) {
list.add(Text.translatable("item.unicopia.amulet.energy", (int)Math.floor(getEnergy(stack)), maxEnergy));
list.add(new TranslatableText("item.unicopia.amulet.energy", (int)Math.floor(getEnergy(stack)), maxEnergy));
}
}

View file

@ -19,6 +19,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.WorldEvents;
@ -31,7 +32,7 @@ public class FilledJarItem extends JarItem implements ChameleonItem {
@Override
public Text getName(ItemStack stack) {
return hasAppearance(stack) ? Text.translatable(getTranslationKey(stack), getAppearanceStack(stack).getName()) : UItems.EMPTY_JAR.getName(UItems.EMPTY_JAR.getDefaultStack());
return hasAppearance(stack) ? new TranslatableText(getTranslationKey(stack), getAppearanceStack(stack).getName()) : UItems.EMPTY_JAR.getName(UItems.EMPTY_JAR.getDefaultStack());
}
@Override

View file

@ -25,6 +25,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.stat.Stats;
import net.minecraft.text.Text;
import net.minecraft.util.*;
import net.minecraft.text.TranslatableText;
import net.minecraft.world.World;
public class FriendshipBraceletItem extends WearableItem implements DyeableItem, GlowableItem {
@ -68,10 +69,10 @@ public class FriendshipBraceletItem extends WearableItem implements DyeableItem,
@Environment(EnvType.CLIENT)
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> list, TooltipContext tooltipContext) {
if (isSigned(stack)) {
list.add(Text.translatable("item.unicopia.friendship_bracelet.issuer", getSignatorName(stack)));
list.add(new TranslatableText("item.unicopia.friendship_bracelet.issuer", getSignatorName(stack)));
}
if (isGlowing(stack)) {
list.add(Text.translatable("item.unicopia.friendship_bracelet.glowing").formatted(Formatting.ITALIC, Formatting.GRAY));
list.add(new TranslatableText("item.unicopia.friendship_bracelet.glowing").formatted(Formatting.ITALIC, Formatting.GRAY));
}
}

View file

@ -20,8 +20,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.*;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
@ -79,7 +78,7 @@ public class GemstoneItem extends Item {
if (isEnchanted(stack)) {
SpellType<?> key = getSpellKey(stack);
MutableText line = Text.translatable(key.getTranslationKey() + ".lore").formatted(key.getAffinity().getColor());
MutableText line = new TranslatableText(key.getTranslationKey() + ".lore").formatted(key.getAffinity().getColor());
if (!Unicopia.SIDE.getPlayerSpecies().canCast()) {
line = line.formatted(Formatting.OBFUSCATED);
@ -112,10 +111,10 @@ public class GemstoneItem extends Item {
public Text getName(ItemStack stack) {
if (isEnchanted(stack)) {
if (!Unicopia.SIDE.getPlayerSpecies().canCast()) {
return Text.translatable(getTranslationKey(stack) + ".obfuscated");
return new TranslatableText(getTranslationKey(stack) + ".obfuscated");
}
return Text.translatable(getTranslationKey(stack) + ".enchanted", getSpellKey(stack).getName());
return new TranslatableText(getTranslationKey(stack) + ".enchanted", getSpellKey(stack).getName());
}
return super.getName();
}

View file

@ -113,7 +113,7 @@ public interface UItems {
return register(name, new MusicDiscItem(1, sound, new Settings()
.maxCount(1)
.group(ItemGroup.MISC)
.rarity(Rarity.RARE), seconds
.rarity(Rarity.RARE)
) {});
}

View file

@ -1,11 +1,10 @@
package com.minelittlepony.unicopia.item;
import java.util.List;
import com.google.gson.JsonArray;
import com.minelittlepony.unicopia.ability.magic.spell.crafting.*;
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
import net.fabricmc.fabric.api.loot.v1.FabricLootSupplier;
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
import net.minecraft.loot.LootTable;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeSerializer;
@ -39,7 +38,7 @@ public interface URecipes {
}
static void bootstrap() {
LootTableEvents.MODIFY.register((res, manager, id, supplier, setter) -> {
LootTableLoadingCallback.EVENT.register((res, manager, id, supplier, setter) -> {
if (!"minecraft".contentEquals(id.getNamespace())) {
return;
}
@ -47,7 +46,7 @@ public interface URecipes {
Identifier modId = new Identifier("unicopiamc", id.getPath());
LootTable table = manager.getTable(modId);
if (table != LootTable.EMPTY) {
supplier.pools(List.of(table.pools));
supplier.withPools(((FabricLootSupplier)table).getPools());
}
});
}

View file

@ -1,8 +1,8 @@
package com.minelittlepony.unicopia.item.enchantment;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;
@ -20,7 +20,6 @@ import net.minecraft.resource.ResourceManager;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.util.registry.Registry;
@ -72,11 +71,13 @@ public class PoisonedJokeEnchantment extends SimpleEnchantment implements Identi
clientProfiler.startTick();
clientProfiler.push("Loading poisoned joke sound options");
sounds = Resources.getResources(manager, FILE)
.flatMap(r -> Resources.loadFile(r, TYPE, "Failed to load sounds file at "))
.distinct()
.flatMap(this::findSound)
.collect(Collectors.toList());
try {
sounds = Resources.getResources(manager, FILE)
.flatMap(r -> Resources.loadFile(r, TYPE, "Failed to load sounds file at "))
.distinct()
.flatMap(this::findSound)
.collect(Collectors.toList());
} catch (IOException e) {}
clientProfiler.pop();
clientProfiler.endTick();

View file

@ -6,6 +6,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
public enum Toxicity {
@ -28,7 +29,7 @@ public enum Toxicity {
}
public Text getTooltip() {
return Text.translatable(getTranslationKey()).formatted(color);
return new TranslatableText(getTranslationKey()).formatted(color);
}
public static Toxicity byName(String name) {

View file

@ -10,8 +10,7 @@ import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.*;
import net.minecraft.util.StringHelper;
import net.minecraft.world.Difficulty;
@ -92,10 +91,10 @@ public interface Toxin extends Affliction {
MutableText text = effect.getName().copy();
if (amplifier > 0) {
text = Text.translatable("potion.withAmplifier", text, Text.translatable("potion.potency." + amplifier));
text = new TranslatableText("potion.withAmplifier", text, new TranslatableText("potion.potency." + amplifier));
}
text = Text.translatable("potion.withDuration", text, StringHelper.formatTicks(ticks));
text = new TranslatableText("potion.withDuration", text, StringHelper.formatTicks(ticks));
return of(text, (player, stack) -> {
StatusEffectInstance current = player.getStatusEffect(effect);

View file

@ -24,7 +24,7 @@ abstract class MixinBoatEntity extends Entity implements LavaAffine {
@Redirect(
method = {
"getWaterHeightBelow",
"method_7544",
"checkBoatInWater",
"getUnderWaterLocation",
"fall",

View file

@ -11,6 +11,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
@Mixin(DamageSource.class)
abstract class MixinDamageSource {
@ -22,11 +23,11 @@ abstract class MixinDamageSource {
Entity prime = entity.getPrimeAdversary();
if (prime != null && !(attacker instanceof Owned<?> && ((Owned<Entity>)attacker).isOwnedBy(prime))) {
info.setReturnValue(Text.translatable("death.attack.generic.and_also", info.getReturnValue(), attacker.getDisplayName()));
info.setReturnValue(new TranslatableText("death.attack.generic.and_also", info.getReturnValue(), attacker.getDisplayName()));
return;
}
info.setReturnValue(Text.translatable("death.attack." + self.getName() + ".player", entity.getDisplayName(), attacker.getDisplayName()));
info.setReturnValue(new TranslatableText("death.attack." + self.getName() + ".player", entity.getDisplayName(), attacker.getDisplayName()));
});
}
}

View file

@ -16,7 +16,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
@Mixin(ServerPlayerEntity.class)
abstract class MixinServerPlayerEntity extends PlayerEntity implements ScreenHandlerListener, PonyContainer<Pony>, ServerPlayerEntityDuck {
MixinServerPlayerEntity() {super(null, null, 0, null, null);}
MixinServerPlayerEntity() {super(null, null, 0, null);}
@Override
@Accessor("inTeleportationState")

View file

@ -15,7 +15,7 @@ import net.minecraft.world.World;
@Mixin(ServerWorld.class)
abstract class MixinServerWorld extends World implements StructureWorldAccess {
MixinServerWorld() { super(null, null, null, null, false, false, 0, 0); }
MixinServerWorld() { super(null, null, null, null, false, false, 0); }
@Inject(method = "onBlockChanged", at = @At("HEAD"))
private void onOnBlockChanged(BlockPos pos, BlockState oldState, BlockState newState, CallbackInfo info) {

View file

@ -13,8 +13,8 @@ import net.minecraft.client.input.KeyboardInput;
@Mixin(KeyboardInput.class)
abstract class MixinKeyboardInput extends Input {
@Inject(method = "tick(ZF)V", at = @At("RETURN"))
private void onTick(boolean a, float b, CallbackInfo info) {
@Inject(method = "tick(Z)V", at = @At("RETURN"))
private void onTick(boolean a, CallbackInfo info) {
Pony player = Pony.of(MinecraftClient.getInstance().player);
if (player != null && player.getPhysics().isGravityNegative()) {

View file

@ -32,7 +32,7 @@ public class MsgPlayerCapabilities implements Packet<PlayerEntity> {
MsgPlayerCapabilities(PacketByteBuf buffer) {
playerId = buffer.readUuid();
newRace = buffer.readRegistryValue(Race.REGISTRY);
newRace = Race.REGISTRY.get(buffer.readIdentifier());
try (InputStream in = new ByteBufInputStream(buffer)) {
compoundTag = NbtIo.readCompressed(in);
} catch (IOException e) {
@ -49,7 +49,7 @@ public class MsgPlayerCapabilities implements Packet<PlayerEntity> {
@Override
public void toBuffer(PacketByteBuf buffer) {
buffer.writeUuid(playerId);
buffer.writeRegistryValue(Race.REGISTRY, newRace);
buffer.writeIdentifier(Race.REGISTRY.getId(newRace));
try (OutputStream out = new ByteBufOutputStream(buffer)) {
NbtIo.writeCompressed(compoundTag, out);
} catch (IOException e) {

View file

@ -21,7 +21,7 @@ public class MsgRequestSpeciesChange implements Packet<ServerPlayerEntity> {
MsgRequestSpeciesChange(PacketByteBuf buffer) {
force = buffer.readBoolean();
newRace = buffer.readRegistryValue(Race.REGISTRY);
newRace = Race.REGISTRY.get(buffer.readIdentifier());
}
public MsgRequestSpeciesChange(Race newRace) {
@ -36,7 +36,7 @@ public class MsgRequestSpeciesChange implements Packet<ServerPlayerEntity> {
@Override
public void toBuffer(PacketByteBuf buffer) {
buffer.writeBoolean(force);
buffer.writeRegistryValue(Race.REGISTRY, newRace);
buffer.writeIdentifier(Race.REGISTRY.getId(newRace));
}
@Override

View file

@ -22,7 +22,7 @@ public class MsgTribeSelect implements Packet<PlayerEntity> {
int len = buffer.readInt();
availableRaces = new HashSet<>();
while (len-- > 0) {
availableRaces.add(buffer.readRegistryValue(Race.REGISTRY));
availableRaces.add(Race.REGISTRY.get(buffer.readIdentifier()));
}
}
@ -33,7 +33,7 @@ public class MsgTribeSelect implements Packet<PlayerEntity> {
@Override
public void toBuffer(PacketByteBuf buffer) {
buffer.writeInt(availableRaces.size());
availableRaces.forEach(race -> buffer.writeRegistryValue(Race.REGISTRY, race));
availableRaces.forEach(race -> buffer.writeIdentifier(Race.REGISTRY.getId(race)));
}
@Override

View file

@ -1,6 +1,7 @@
package com.minelittlepony.unicopia.particle;
import java.util.Locale;
import java.util.Random;
import com.minelittlepony.common.util.Color;
import com.mojang.brigadier.StringReader;
@ -11,7 +12,6 @@ import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleType;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.registry.Registry;
public class MagicParticleEffect implements ParticleEffect {

View file

@ -13,6 +13,7 @@ import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.damage.EntityDamageSource;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
public class MagicalDamageSource extends EntityDamageSource {
@ -89,6 +90,6 @@ public class MagicalDamageSource extends EntityDamageSource {
params.add(item.toHoverableText());
}
return Text.translatable(basic, params.toArray());
return new TranslatableText(basic, params.toArray());
}
}

View file

@ -21,7 +21,7 @@ public interface Resources {
.registerTypeAdapter(Identifier.class, new ToStringAdapter<>(Identifier::new))
.create();
static Stream<Resource> getResources(ResourceManager manager, Identifier id) {
static Stream<Resource> getResources(ResourceManager manager, Identifier id) throws IOException {
return manager.getAllResources(id).stream();
}

View file

@ -1,8 +1,9 @@
package com.minelittlepony.unicopia.util.shape;
import java.util.Random;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
public class Cylinder implements Shape {

View file

@ -1,8 +1,9 @@
package com.minelittlepony.unicopia.util.shape;
import java.util.Random;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
/**
* A lonely Line. The simplest form of shape.

View file

@ -1,5 +1,6 @@
package com.minelittlepony.unicopia.util.shape;
import java.util.Random;
import java.util.Spliterator;
import java.util.Spliterators.AbstractSpliterator;
import java.util.concurrent.atomic.AtomicInteger;
@ -10,7 +11,6 @@ import java.util.stream.StreamSupport;
import com.google.common.collect.Streams;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
/**
*

View file

@ -1,8 +1,9 @@
package com.minelittlepony.unicopia.util.shape;
import java.util.Random;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
/**
* A sphere, or 2d circle of you so desire.