Skip to content

Commit

Permalink
Merge branch '1.20.1' into 1.20.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java
#	src/main/java/com/minelittlepony/unicopia/client/minelittlepony/Main.java
  • Loading branch information
Sollace committed Feb 15, 2024
2 parents 0de1847 + ae8068c commit cef99f4
Show file tree
Hide file tree
Showing 91 changed files with 961 additions and 189 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Unicorns, Pegasi, Earth Ponies, and even Changelings get their own special abili

### Manage your diet

Playing as a pony isn't all just kicking and zapping, though! As herbivores your food options open up to include
Playing as a pony isn't all just kicking and zapping, though! As herbivores, your food options open up to include
a lot of items normal players don't usually get to eat. Feeling peckish? Try for some flowers from the meadow,
or some hay! I hear the hay burgers of good, if you can find some oats.

Expand All @@ -57,21 +57,24 @@ Unicorns, Pegasi, Earth Ponies, and even Changelings get their own special abili
### Natural Stuff

- Airflow is simulated (badly)
Pegasi, beware about flying during storms! It can get dangerous out there!
If you're playing as a flying species, or just like having nice things, try building a weather vane.

Pegasi, beware of flying during storms! It can get dangerous out there!
If you're playing as a flying species, or just like having nice things, try building a weather vein.

It shows the actual, totally real and not simulated badly, wind direction of your minecraft world. Just beware
that the direction and strength is situational (and bad), and will be different depending where you are and
that the direction and strength are situational (and bad), and will be different depending on where you are and
how high up you are.

- Hot air Rises

No, it's not a bad Star Wars movie, it's an actual mechanic. Sand and lava will give flying species extra lift. Water does the opposite.
Try it! Actually don't, I don't want you to drown.

### Magic Items And Artifacts

- Craft and build s shrine for the Crystal Heart to provide valuable support to your friends
- Or give out bangles of comradery to your non-unicorn buddies so they can share in your powers,
or just so you can laugh when you teleport and they end up coming witht
- Craft and build a shrine for the Crystal Heart to provide valuable support to your friends
- Or give out bangles of comradery to your non-unicorn buddies, so they can share in your powers,
or just so you can laugh when you teleport and they end up coming with
- Send and receive items using the Dragon's Breath Scroll
- Possibly more I'm forgetting about (or am I? OoOoOooOOoo...Spooky surprise mechanics)

Expand All @@ -88,7 +91,7 @@ View the HOW_TO_PLAY.md file for more details.
### 1.19.3 Only

This project uses reach-entity-attributes, which may not be updated at the time of this writing.
If you building for 1.19.3, you may follow these steps to make sure it's available to git:
If you're building for 1.19.3, you may follow these steps to make sure it's available to git:

`git clone https://github.com/Sollace/reach-entity-attributes`
`cd reach-entity-attributes`
Expand Down
13 changes: 8 additions & 5 deletions README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,22 @@

### Понифицированные картины

Ведь что это был бы за пони-мод, если бы в нём не было этого? У каждой расы есть хотя бы один рисунок, представляющий её,
Ведь что это был бы за пони-мод, если бы в нём _не_ было этого? У каждой расы есть хотя бы один рисунок, представляющий её,
так что покажите свою гордость и поднимите флаг!

Дисклеймер: Радужных флагов нет (пока)
Дисклеймер: Радужных флагов (пока) нет

### Природные явления

- Воздушный поток (плохо) влияет на пегасов, остерегайтесь летать во время грозы! Там может быть опасно!
Если вы играете за летающий вид или просто любите приятные вещи, попробуйте построить метеорологическую жилу.
- Воздушный поток

Пегасы, остерегайтесь полётов во время грозы! Это может быть опасно!
Если вы играете за летающий вид или просто любите приятные вещи, попробуйте построить погодную жилу.
Она показывает фактическое, абсолютно реальное, а не плохо смоделированное направление ветра в вашем мире Minecraft. Только учтите,
что направление и сила ветра ситуативны (и плохи), и будут отличаться в зависимости от того, где вы находитесь и на какой высоте.
что направление и сила ветра ситуативны, и будут отличаться в зависимости от того, где вы находитесь и на какой высоте.

- Горячий воздух поднимает

Нет, это не плохой фильм про "Звездные войны", это реальная механика. Песок и лава придают летающим видам дополнительную подъёмную силу.
Вода - наоборот. Попробуйте! А вообще, не стоит, я не хочу чтобы вы утонули.

Expand Down
57 changes: 57 additions & 0 deletions src/main/java/com/minelittlepony/unicopia/AllowList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.minelittlepony.unicopia;

import java.util.Set;

public class AllowList {
public static final AllowList INSTANCE = new AllowList();

public AllowList() {

}

public boolean disable() {
if (!isEnabled()) {
return false;
}
Unicopia.getConfig().speciesWhiteList.get().clear();
Unicopia.getConfig().save();
return true;
}

public boolean isEnabled() {
return !Unicopia.getConfig().speciesWhiteList.get().isEmpty();
}

public boolean add(Race race) {
if (race.isUnset() || race.isHuman()) {
return false;
}
Set<String> values = Unicopia.getConfig().speciesWhiteList.get();
boolean added = values.add(race.getId().toString());
Unicopia.getConfig().save();
return added;
}

public boolean remove(Race race) {
Set<String> values = Unicopia.getConfig().speciesWhiteList.get();
if (values.isEmpty()) {
for (Race r : Race.REGISTRY) {
if (!r.isUnset() && r != race) {
values.add(r.getId().toString());
}
}
Unicopia.getConfig().save();
return true;
}
boolean removed = values.remove(race.getId().toString());
Unicopia.getConfig().save();
return removed;
}

public boolean permits(Race race) {
return race.isUnset()
|| race.isHuman()
|| !isEnabled()
|| Unicopia.getConfig().speciesWhiteList.get().contains(race.getId().toString());
}
}
15 changes: 6 additions & 9 deletions src/main/java/com/minelittlepony/unicopia/Race.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.command.argument.RegistryKeyArgumentType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.registry.Registry;
Expand Down Expand Up @@ -133,20 +134,16 @@ public Identifier getIcon() {
}

public boolean isPermitted(@Nullable PlayerEntity sender) {
Set<String> whitelist = Unicopia.getConfig().speciesWhiteList.get();

return isUnset()
|| whitelist.isEmpty()
|| whitelist.contains(getId().toString());
return AllowList.INSTANCE.permits(this);
}

public Race validate(PlayerEntity sender) {
if (!isPermitted(sender)) {
if (this == EARTH) {
return HUMAN;
Race alternative = this == EARTH ? HUMAN : EARTH.validate(sender);
if (alternative != this && sender instanceof ServerPlayerEntity spe) {
spe.sendMessageToClient(Text.translatable("respawn.reason.illegal_race", getDisplayName()), false);
}

return EARTH.validate(sender);
return alternative;
}

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public boolean canUse(Race race) {
@Override
public Identifier getIcon(Pony player) {
return getId().withPath(p -> "textures/gui/ability/" + p
+ "_" + player.getObservedSpecies().getId().getPath()
+ "_" + (player.getObservedSpecies().isHuman() ? Race.EARTH : player.getObservedSpecies()).getId().getPath()
+ "_" + (getKickDirection(player) > 0 ? "forward" : "backward")
+ ".png");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ public boolean canUse(Race race) {
@Override
public Identifier getIcon(Pony player) {
Identifier id = Abilities.REGISTRY.getId(this);
Race race = player.getObservedSpecies();
return new Identifier(id.getNamespace(), "textures/gui/ability/" + id.getPath()
+ "_" + player.getObservedSpecies().getId().getPath()
+ "_" + (race.isHuman() ? Race.EARTH : race).getId().getPath()
+ ".png");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public boolean canUse(Race race) {

@Override
public boolean canUse(Race.Composite race) {
return race.pseudo() == Race.UNICORN;
return Ability.super.canUse(race) || race.pseudo() == Race.UNICORN;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ public Hit.Serializer<Hit> getSerializer() {
@Override
public Identifier getIcon(Pony player) {
Identifier id = Abilities.REGISTRY.getId(this);
Race race = player.getObservedSpecies();
return new Identifier(id.getNamespace(), "textures/gui/ability/" + id.getPath()
+ (player.getPhysics().isFlying() ? "_land" : "_takeoff")
+ "_" + player.getObservedSpecies().getId().getPath()
+ "_" + (race.isHuman() ? Race.EARTH : race).getId().getPath()
+ ".png");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public void toNBT(NbtCompound compound) {

@Override
public void fromNBT(NbtCompound compound) {
fromNBT(compound, true);
}

public void fromNBT(NbtCompound compound, boolean force) {
final int hash = compound.hashCode();
if (nbtHash == hash) {
return;
Expand All @@ -58,7 +62,7 @@ public void fromNBT(NbtCompound compound) {

if (spell == null || !Objects.equals(Spell.getUuid(compound), spell.getUuid())) {
spell = Spell.readNbt(compound);
} else {
} else if (force || !spell.isDirty()) {
spell.fromNBT(compound);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.minelittlepony.unicopia.client;

import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import net.minecraft.client.MinecraftClient;
import net.minecraft.text.*;

public interface FlowingText {
public interface TextHelper {
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("");
Expand All @@ -17,4 +19,11 @@ static Stream<Text> wrap(Text text, int maxWidth) {
return compiled;
});
}

static Text join(Text delimiter, Iterable<? extends MutableText> elements) {
MutableText initial = Text.empty();
return StreamSupport.stream(elements.spliterator(), false).collect(Collectors.reducing(initial, (a, b) -> {
return a == initial ? b : a.append(delimiter).append(b);
}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static void bootstrap() {
AccessoryFeatureRenderer.register(
BraceletFeatureRenderer::new, AmuletFeatureRenderer::new, GlassesFeatureRenderer::new,
WingsFeatureRenderer::new, HornFeatureRenderer::new, IcarusWingsFeatureRenderer::new, BatWingsFeatureRenderer::new,
HeldEntityFeatureRenderer::new
HeldEntityFeatureRenderer::new, DisguisedArmsFeatureRenderer::new
);

EntityRendererRegistry.register(UEntities.THROWN_ITEM, FlyingItemEntityRenderer::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
import com.minelittlepony.unicopia.ability.magic.spell.*;
import com.minelittlepony.unicopia.client.FlowingText;
import com.minelittlepony.unicopia.client.TextHelper;
import com.minelittlepony.unicopia.client.render.model.SphereModel;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.UItems;
Expand Down Expand Up @@ -195,7 +195,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float tickDelta)
tooltip.add(ScreenTexts.EMPTY);
tooltip.add(Text.translatable("gui.unicopia.dispell_screen.affinity", 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.addAll(TextHelper.wrap(Text.translatable(actualSpell.getType().getTranslationKey() + ".lore").formatted(actualSpell.getAffinity().getColor()), 180).toList());
if (spell instanceof TimedSpell timed) {
tooltip.add(ScreenTexts.EMPTY);
tooltip.add(Text.translatable("gui.unicopia.dispell_screen.time_left", StringHelper.formatTicks(timed.getTimer().getTicksRemaining())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public TribeConfirmationScreen(BooleanConsumer callback, Race selection) {

@Override
protected void init() {
if (parent != null) {
parent.init(client, width, height);
}
final int columnHeight = 167;
final int columnWidth = 310;
final int padding = 15;
Expand Down Expand Up @@ -101,6 +104,13 @@ private void buildTextBody() {

@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
if (parent != null) {
context.getMatrices().push();
context.getMatrices().translate(0, 0, -100);
parent.render(context, 0, 0, delta);
context.getMatrices().pop();
}

final int columnHeight = 180;
final int columnWidth = 310;
final int segmentWidth = 123;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ protected void init() {
addOption(race, top);
}

if (SELECTION == -1) {
SELECTION = options.size() / 2;
}
scroll(SELECTION, false);
scroll(SELECTION == -1 ? options.size() / 2 : SELECTION, false);
}

private void addOption(Race race, int y) {
Expand Down Expand Up @@ -159,18 +156,21 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
return true;
}
if (keyCode == GLFW.GLFW_KEY_ENTER) {
options.get(SELECTION).onPress();
if (options.get(SELECTION).active) {
options.get(SELECTION).onPress();
}
}

return super.keyPressed(keyCode, scanCode, modifiers);
}

private void scroll(int target, boolean animate) {
if (target == SELECTION) {
SELECTION = target;
target *= 4;
if (targetScroll == target) {
return;
}
SELECTION = target;
targetScroll = SELECTION * 4;
targetScroll = target;
if (!animate) {
scrollPosition = targetScroll;
prevScrollPosition = scrollPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
import com.minelittlepony.unicopia.client.FlowingText;
import com.minelittlepony.unicopia.client.TextHelper;
import com.minelittlepony.unicopia.client.gui.*;
import com.minelittlepony.unicopia.client.gui.spellbook.SpellbookChapterList.*;
import com.minelittlepony.unicopia.compat.trinkets.TrinketSlotBackSprites;
Expand Down Expand Up @@ -218,7 +218,7 @@ protected void drawMouseoverTooltip(DrawContext context, int x, int y) {

List<Text> tooltip = new ArrayList<>();
tooltip.add(spell.type().getName());
tooltip.addAll(FlowingText.wrap(Text.translatable(spell.type().getTranslationKey() + ".lore").formatted(spell.type().getAffinity().getColor()), 180).toList());
tooltip.addAll(TextHelper.wrap(Text.translatable(spell.type().getTranslationKey() + ".lore").formatted(spell.type().getAffinity().getColor()), 180).toList());


context.drawTooltip(textRenderer, tooltip, x, y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.magic.spell.trait.*;
import com.minelittlepony.unicopia.client.FlowingText;
import com.minelittlepony.unicopia.client.TextHelper;
import com.minelittlepony.unicopia.client.gui.spellbook.SpellbookChapterList.Chapter;
import com.minelittlepony.unicopia.client.gui.spellbook.SpellbookScreen.ImageButton;
import com.minelittlepony.unicopia.container.SpellbookState;
Expand Down Expand Up @@ -191,7 +191,7 @@ public TraitButton(int x, int y, Trait trait) {
.setTextureSize(16, 16)
.setSize(16, 16)
.setTexture(trait.getSprite()));
getStyle().setTooltip(Tooltip.of(FlowingText.wrap(trait.getTooltip(), 200).toList()));
getStyle().setTooltip(Tooltip.of(TextHelper.wrap(trait.getTooltip(), 200).toList()));

onClick(sender -> Pony.of(MinecraftClient.getInstance().player).getDiscoveries().markRead(trait));
}
Expand Down
Loading

0 comments on commit cef99f4

Please sign in to comment.