Skip to content

Commit

Permalink
Update to 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Jun 6, 2022
1 parent f1b640d commit 3245026
Show file tree
Hide file tree
Showing 22 changed files with 225 additions and 370 deletions.
13 changes: 7 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
id "com.modrinth.minotaur" version "2.+"
id 'com.matthewprenger.cursegradle' version '1.4.0'
Expand Down Expand Up @@ -56,11 +56,11 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"


modImplementation include("eu.pb4:sgui:1.0.2+1.18.2")
modImplementation include("eu.pb4:hologram-api:0.2.1+1.18-pre5")
modImplementation include("eu.pb4:placeholder-api:1.1.3+1.17.1")
modImplementation include("eu.pb4:polymer:0.2.0-rc.2+1.18.2")
modImplementation include("fr.catcore:server-translations-api:1.4.12+1.18.2")
modImplementation include("eu.pb4:sgui:1.1.0+1.19")
modImplementation include("eu.pb4:hologram-api:0.2.2+1.19")
modImplementation include("eu.pb4:placeholder-api:2.0.0-beta.2+1.19")
modImplementation include("eu.pb4:polymer:0.2.0-rc.4+1.19-rc2")
modImplementation include("fr.catcore:server-translations-api:1.4.14+1.19-rc2")
//modImplementation include("fr.catcore:server-translations-api:1.4.8+1.18-pre1")
modImplementation include("me.lucko:fabric-permissions-api:0.1-SNAPSHOT")

Expand Down Expand Up @@ -142,6 +142,7 @@ curseforge {
changelogType = "markdown"
addGameVersion ((String) project.minecraft_version)
addGameVersion "Fabric"
addGameVersion "Quilt"
mainArtifact(remapJar)

afterEvaluate {
Expand Down
12 changes: 7 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.2
loader_version=0.13.3
minecraft_version=1.19-rc2
yarn_mappings=1.19-rc2+build.1
loader_version=0.14.6

#Fabric api
fabric_version=0.48.0+1.18.2
fabric_version=0.55.0+1.19


# Mod Properties
mod_version = 2.0.3+1.18.2
mod_version = 2.0.4+1.19
maven_group = eu.pb4
archives_base_name = graves

Expand Down
32 changes: 16 additions & 16 deletions src/main/java/eu/pb4/graves/GenericModInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void build(ModContainer container) {
var source = ImageIO.read(Files.newInputStream(container.getPath("assets/logo_mini.png")));

for (int y = 0; y < source.getHeight(); y++) {
var base = new LiteralText("");
var base = Text.literal("");
int line = 0;
int color = source.getRGB(0, y) & 0xFFFFFF;
for (int x = 0; x < source.getWidth(); x++) {
Expand All @@ -33,19 +33,19 @@ public static void build(ModContainer container) {
if (color == colorPixel) {
line++;
} else {
base.append(new LiteralText(chr.repeat(line)).setStyle(Style.EMPTY.withColor(color)));
base.append(Text.literal(chr.repeat(line)).setStyle(Style.EMPTY.withColor(color)));
color = colorPixel;
line = 1;
}
}

base.append(new LiteralText(chr.repeat(line)).setStyle(Style.EMPTY.withColor(color)));
base.append(Text.literal(chr.repeat(line)).setStyle(Style.EMPTY.withColor(color)));
icon.add(base);
}
} catch (Throwable e) {
e.printStackTrace();
while (icon.size() < 16) {
icon.add(new LiteralText("/!\\ [ Invalid icon file ] /!\\").setStyle(Style.EMPTY.withColor(0xFF0000).withItalic(true)));
icon.add(Text.literal("/!\\ [ Invalid icon file ] /!\\").setStyle(Style.EMPTY.withColor(0xFF0000).withItalic(true)));
}
}

Expand All @@ -58,28 +58,28 @@ public static void build(ModContainer container) {
var output = new ArrayList<Text>();

try {
about.add(new LiteralText(container.getMetadata().getName()).setStyle(Style.EMPTY.withColor(0x00e6b4).withBold(true).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,container.getMetadata().getContact().get("github").orElse("")))));
about.add(new TranslatableText("text.graves.about.version").setStyle(Style.EMPTY.withColor(0xf7e1a7))
.append(new LiteralText(container.getMetadata().getVersion().getFriendlyString()).setStyle(Style.EMPTY.withColor(Formatting.WHITE))));
about.add(Text.literal(container.getMetadata().getName()).setStyle(Style.EMPTY.withColor(0x00e6b4).withBold(true).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,container.getMetadata().getContact().get("github").orElse("")))));
about.add(Text.translatable("text.graves.about.version").setStyle(Style.EMPTY.withColor(0xf7e1a7))
.append(Text.literal(container.getMetadata().getVersion().getFriendlyString()).setStyle(Style.EMPTY.withColor(Formatting.WHITE))));

aboutBasic.addAll(about);
aboutBasic.add(LiteralText.EMPTY);
aboutBasic.add(Text.empty());
aboutBasic.add(Text.of(container.getMetadata().getDescription()));

var contributors = new ArrayList<String>();
contributors.addAll(container.getMetadata().getAuthors().stream().map((p) -> p.getName()).collect(Collectors.toList()));
contributors.addAll(container.getMetadata().getContributors().stream().map((p) -> p.getName()).collect(Collectors.toList()));

about.add(new LiteralText("")
.append(new TranslatableText("text.graves.about.contributors")
about.add(Text.literal("")
.append(Text.translatable("text.graves.about.contributors")
.setStyle(Style.EMPTY.withColor(Formatting.AQUA)
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
new LiteralText(String.join(", ", contributors)
Text.literal(String.join(", ", contributors)
))
)))
.append("")
.setStyle(Style.EMPTY.withColor(Formatting.DARK_GRAY)));
about.add(LiteralText.EMPTY);
about.add(Text.empty());

var desc = new ArrayList<>(List.of(container.getMetadata().getDescription().split(" ")));

Expand All @@ -89,21 +89,21 @@ public static void build(ModContainer container) {
(descPart.isEmpty() ? descPart : descPart.append(" ")).append(desc.remove(0));

if (descPart.length() > 16) {
about.add(new LiteralText(descPart.toString()).setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
about.add(Text.literal(descPart.toString()).setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
descPart = new StringBuilder();
}
}

if (descPart.length() > 0) {
about.add(new LiteralText(descPart.toString()).setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
about.add(Text.literal(descPart.toString()).setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
}
}

if (icon.length > about.size() + 2) {
int a = 0;
for (int i = 0; i < icon.length; i++) {
if (i == (icon.length - about.size() - 1) / 2 + a && a < about.size()) {
output.add(icon[i].shallowCopy().append(new LiteralText(" ").setStyle(Style.EMPTY.withItalic(false)).append(about.get(a++))));
output.add(icon[i].copy().append(Text.literal(" ").setStyle(Style.EMPTY.withItalic(false)).append(about.get(a++))));
} else {
output.add(icon[i]);
}
Expand All @@ -114,7 +114,7 @@ public static void build(ModContainer container) {
}
} catch (Exception e) {
e.printStackTrace();
var invalid = new LiteralText("/!\\ [ Invalid about mod info ] /!\\").setStyle(Style.EMPTY.withColor(0xFF0000).withItalic(true));
var invalid = Text.literal("/!\\ [ Invalid about mod info ] /!\\").setStyle(Style.EMPTY.withColor(0xFF0000).withItalic(true));

output.add(invalid);
about.add(invalid);
Expand Down
24 changes: 16 additions & 8 deletions src/main/java/eu/pb4/graves/GraveNetworking.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import eu.pb4.graves.config.ConfigManager;
import eu.pb4.graves.other.VisualGraveData;
import eu.pb4.placeholders.PlaceholderAPI;
import eu.pb4.polymer.api.item.PolymerItemUtils;
import eu.pb4.placeholders.api.Placeholders;
import eu.pb4.polymer.api.networking.PolymerPacketUtils;
import eu.pb4.polymer.api.networking.PolymerSyncUtils;
import fr.catcore.server.translations.api.LocalizationTarget;
Expand Down Expand Up @@ -64,19 +63,28 @@ public static boolean sendGrave(ServerPlayNetworkHandler handler, BlockPos block
if (version == 0 && config.canClientSide) {
var target = (LocalizationTarget) handler.getPlayer();

var texts = textOverrides != null ? textOverrides : locked ? config.signProtectedText : config.signText;

var buf = PolymerPacketUtils.buf(0);
buf.writeBlockPos(blockPos);
buf.writeNbt(data.toNbt());
buf.writeVarInt(texts.length);

for (var text : texts) {
buf.writeString(Text.Serializer.toJson(
LocalizableText.asLocalizedFor(PlaceholderAPI.parsePredefinedText(text, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, placeholders), target)
));
if (textOverrides != null) {
buf.writeVarInt(textOverrides.length);
for (var text : textOverrides) {
buf.writeString(Text.Serializer.toJson(text));
}
} else {
var texts = locked ? config.signProtectedText : config.signText;

buf.writeVarInt(texts.length);
for (var text : texts) {
buf.writeString(Text.Serializer.toJson(
LocalizableText.asLocalizedFor(Placeholders.parseText(text, Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, placeholders), target)
));
}
}


PolymerPacketUtils.sendPacket(handler, SERVER_GRAVE, buf);
return true;
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/eu/pb4/graves/client/GraveRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import net.minecraft.state.property.Properties;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.random.Random;
import org.jetbrains.annotations.Nullable;

import java.util.Map;
import java.util.Random;

import static eu.pb4.graves.registry.AbstractGraveBlock.IS_LOCKED;

Expand Down Expand Up @@ -67,7 +67,7 @@ public void renderHead(AbstractGraveBlockEntity entity, float tickDelta, MatrixS
var client = MinecraftClient.getInstance();
matrixStack.translate(0.1D, -0.65D, 0.1D);
matrixStack.scale(0.8F, 0.8F, 0.8F);
client.getBlockRenderManager().renderBlock(lower, entity.getPos(), entity.getWorld(), matrixStack, vertexConsumers.getBuffer(RenderLayers.getBlockLayer(lower)), true, new Random());
client.getBlockRenderManager().renderBlock(lower, entity.getPos(), entity.getWorld(), matrixStack, vertexConsumers.getBuffer(RenderLayers.getBlockLayer(lower)), true, Random.create());
matrixStack.pop();
}
matrixStack.push();
Expand All @@ -87,7 +87,7 @@ public static RenderLayer getRenderLayer(@Nullable GameProfile profile) {
if (profile != null) {
MinecraftClient minecraftClient = MinecraftClient.getInstance();
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = minecraftClient.getSkinProvider().getTextures(profile);
return map.containsKey(com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN) ? RenderLayer.getEntityTranslucent(minecraftClient.getSkinProvider().loadSkin(map.get(com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN), com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN)) : RenderLayer.getEntityTranslucent(DefaultSkinHelper.getTexture(PlayerEntity.getUuidFromProfile(profile)));
return map.containsKey(com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN) ? RenderLayer.getEntityTranslucent(minecraftClient.getSkinProvider().loadSkin(map.get(com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN), com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN)) : RenderLayer.getEntityTranslucent(DefaultSkinHelper.getTexture(profile.getId()));
} else {
return RenderLayer.getEntityCutoutNoCullZOffset(SKULL_TEXTURE);
}
Expand Down Expand Up @@ -125,9 +125,9 @@ public void renderGrave(AbstractGraveBlockEntity entity, float tickDelta, Matrix
var model = entity.getCachedState().get(IS_LOCKED) ? this.graveStoneModel : this.graveStoneUnlockedModel;

if (MinecraftClient.isAmbientOcclusionEnabled() && model.useAmbientOcclusion()) {
renderer.renderSmooth(world, model, entity.getCachedState(), entity.getPos(), matrixStack, vertexConsumers.getBuffer(RenderLayers.getBlockLayer(entity.getCachedState())), false, new Random(), 0, overlay);
renderer.renderSmooth(world, model, entity.getCachedState(), entity.getPos(), matrixStack, vertexConsumers.getBuffer(RenderLayers.getBlockLayer(entity.getCachedState())), false, Random.create(), 0, overlay);
} else {
renderer.renderFlat(world, model, entity.getCachedState(), entity.getPos(), matrixStack, vertexConsumers.getBuffer(RenderLayers.getBlockLayer(entity.getCachedState())), false, new Random(), 0, overlay);
renderer.renderFlat(world, model, entity.getCachedState(), entity.getPos(), matrixStack, vertexConsumers.getBuffer(RenderLayers.getBlockLayer(entity.getCachedState())), false, Random.create(), 0, overlay);
}

matrixStack.push();
Expand Down
Loading

0 comments on commit 3245026

Please sign in to comment.