Skip to content

Commit

Permalink
switch to mojang mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
granny committed Apr 8, 2024
1 parent 8279e18 commit f3143ff
Show file tree
Hide file tree
Showing 112 changed files with 1,399 additions and 1,441 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repositories {

dependencies {
minecraft("com.mojang:minecraft:${project.minecraft_version}")
mappings("net.fabricmc:yarn:${project.yarn_mappings}:v2")
mappings(loom.officialMojangMappings())
modImplementation("net.fabricmc:fabric-loader:${project.loader_version}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")
Expand Down
26 changes: 12 additions & 14 deletions src/main/java/org/purpurmc/purpur/client/PurpurClient.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package org.purpurmc.purpur.client;

import com.google.common.io.ByteArrayDataOutput;
import com.mojang.blaze3d.platform.IconSet;
import com.mojang.blaze3d.platform.Window;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.Icons;
import net.minecraft.client.util.Window;
import net.minecraft.resource.DefaultResourcePack;
import net.minecraft.resource.InputSupplier;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import net.minecraft.client.Minecraft;
import net.minecraft.server.packs.VanillaPackResources;
import net.minecraft.server.packs.resources.IoSupplier;
import org.purpurmc.purpur.client.config.Config;
import org.purpurmc.purpur.client.config.ConfigManager;
import org.purpurmc.purpur.client.network.BeehivePacket;
Expand All @@ -28,7 +26,7 @@ public static PurpurClient instance() {
return instance;
}

public static List<InputSupplier<InputStream>> ICON_LIST = Arrays.asList(() -> PurpurClient.class.getResourceAsStream("/assets/icon16.png"), () -> PurpurClient.class.getResourceAsStream("/assets/icon32.png"));
public static List<IoSupplier<InputStream>> ICON_LIST = Arrays.asList(() -> PurpurClient.class.getResourceAsStream("/assets/icon16.png"), () -> PurpurClient.class.getResourceAsStream("/assets/icon32.png"));

private final ConfigManager configManager;

Expand All @@ -47,7 +45,7 @@ public void onInitializeClient() {

ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
BeehivePacket.numOfBees = null;
if (!client.isInSingleplayer()) {
if (!client.isLocalServer()) {
ByteArrayDataOutput out = Packet.out();
out.writeInt(Constants.PROTOCOL);
Packet.send(Constants.HELLO, out);
Expand All @@ -57,7 +55,7 @@ public void onInitializeClient() {
ClientPlayNetworking.registerGlobalReceiver(Constants.BEEHIVE_S2C, BeehivePacket::receiveBeehiveData);

if (getConfig().useWindowTitle) {
MinecraftClient.getInstance().execute(this::updateTitle);
Minecraft.getInstance().execute(this::updateTitle);
}
}

Expand All @@ -70,12 +68,12 @@ public ConfigManager getConfigManager() {
}

public void updateTitle() {
MinecraftClient client = MinecraftClient.getInstance();
Minecraft client = Minecraft.getInstance();
Window window = client.getWindow();
client.updateWindowTitle();
DefaultResourcePack pack = client.getDefaultResourcePack();
client.updateTitle();
VanillaPackResources pack = client.getVanillaPackResources();
try {
window.setIcon(pack, Icons.RELEASE);
window.setIcon(pack, IconSet.RELEASE);
} catch (IOException e) {
// ignore
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
package org.purpurmc.purpur.client.config.options;

import net.minecraft.client.MinecraftClient;
import net.minecraft.text.OrderedText;
import net.minecraft.text.Text;

import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.util.FormattedCharSequence;

public class BooleanOption implements Option<Boolean> {
private final String key;
private final List<OrderedText> tooltip;
private final List<FormattedCharSequence> tooltip;
private final Getter getter;
private final Setter setter;

private final Text on;
private final Text off;
private final Component on;
private final Component off;

public BooleanOption(String key, Getter getter, Setter setter) {
this.key = "purpurclient.options." + key;
this.tooltip = MinecraftClient.getInstance().textRenderer.wrapLines(Text.translatable(this.key + ".tooltip"), 170);
this.on = Text.translatable("purpurclient.options.on", Text.translatable(this.key));
this.off = Text.translatable("purpurclient.options.off", Text.translatable(this.key));
this.tooltip = Minecraft.getInstance().font.split(Component.translatable(this.key + ".tooltip"), 170);
this.on = Component.translatable("purpurclient.options.on", Component.translatable(this.key));
this.off = Component.translatable("purpurclient.options.off", Component.translatable(this.key));
this.getter = getter;
this.setter = setter;
}
Expand All @@ -31,12 +30,12 @@ public String key() {
}

@Override
public Text text() {
public Component text() {
return get() ? this.on : this.off;
}

@Override
public List<OrderedText> tooltip() {
public List<FormattedCharSequence> tooltip() {
return this.tooltip;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.purpurmc.purpur.client.config.options;

import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
import net.minecraft.network.chat.Component;

public class Button extends ButtonWidget {
public Button(int x, int y, int width, int height, Text message, PressAction onPress) {
super(x, y, width, height, message, onPress, DEFAULT_NARRATION_SUPPLIER);
public class Button extends net.minecraft.client.gui.components.Button {
public Button(int x, int y, int width, int height, Component message, OnPress onPress) {
super(x, y, width, height, message, onPress, DEFAULT_NARRATION);
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package org.purpurmc.purpur.client.config.options;

import net.minecraft.client.MinecraftClient;
import net.minecraft.text.OrderedText;
import net.minecraft.text.Text;

import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.util.FormattedCharSequence;

public class DoubleOption implements Option<Double> {
private final String key;
private final List<OrderedText> tooltip;
private final List<FormattedCharSequence> tooltip;
private final Getter getter;
private final Setter setter;

private Text text;
private Component text;

public DoubleOption(String key, Getter getter, Setter setter) {
this.key = "purpurclient.options." + key;
this.tooltip = MinecraftClient.getInstance().textRenderer.wrapLines(Text.translatable(this.key + ".tooltip"), 170);
this.tooltip = Minecraft.getInstance().font.split(Component.translatable(this.key + ".tooltip"), 170);
this.getter = getter;
this.setter = setter;

Expand All @@ -30,12 +29,12 @@ public String key() {
}

@Override
public Text text() {
public Component text() {
return this.text;
}

@Override
public List<OrderedText> tooltip() {
public List<FormattedCharSequence> tooltip() {
return this.tooltip;
}

Expand All @@ -47,7 +46,7 @@ public Double get() {
@Override
public void set(Double value) {
this.setter.set(Math.round(value * 100.0) / 100.0);
this.text = Text.translatable(this.key, String.format("%.2f", get()));
this.text = Component.translatable(this.key, String.format("%.2f", get()));
}

@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package org.purpurmc.purpur.client.config.options;

import net.minecraft.text.OrderedText;
import net.minecraft.text.Text;

import java.util.List;
import net.minecraft.network.chat.Component;
import net.minecraft.util.FormattedCharSequence;

@SuppressWarnings("unused")
public interface Option<T> {
String key();

Text text();
Component text();

List<OrderedText> tooltip();
List<FormattedCharSequence> tooltip();

T get();

Expand Down
9 changes: 4 additions & 5 deletions src/main/java/org/purpurmc/purpur/client/entity/Mob.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.purpurmc.purpur.client.entity;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.world.entity.EntityType;

public enum Mob {
ALLAY(EntityType.ALLAY, 9, 4),
Expand Down Expand Up @@ -82,16 +81,16 @@ public enum Mob {
ZOMBIE_VILLAGER(EntityType.ZOMBIE_VILLAGER, 7, 4),
ZOMBIFIED_PIGLIN(EntityType.ZOMBIFIED_PIGLIN, 8, 4);

private final EntityType<? extends MobEntity> mob;
private final EntityType<? extends net.minecraft.world.entity.Mob> mob;
private final int u, v;

Mob(EntityType<? extends MobEntity> mob, int u, int v) {
Mob(EntityType<? extends net.minecraft.world.entity.Mob> mob, int u, int v) {
this.mob = mob;
this.u = u;
this.v = v;
}

public EntityType<? extends MobEntity> getType() {
public EntityType<? extends net.minecraft.world.entity.Mob> getType() {
return this.mob;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package org.purpurmc.purpur.client.entity;

import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.Vec3d;
import org.purpurmc.purpur.client.PurpurClient;
import org.purpurmc.purpur.client.config.Seats;

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/org/purpurmc/purpur/client/entity/Seat.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.purpurmc.purpur.client.entity;

import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import org.purpurmc.purpur.client.util.Constants;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/purpurmc/purpur/client/fake/FakePlayer.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package org.purpurmc.purpur.client.fake;

import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.player.LocalPlayer;

public class FakePlayer extends AbstractClientPlayerEntity {
public FakePlayer(ClientWorld world, ClientPlayerEntity player) {
public class FakePlayer extends AbstractClientPlayer {
public FakePlayer(ClientLevel world, LocalPlayer player) {
super(world, player.getGameProfile());
}

@Override
public boolean shouldRenderName() {
public boolean shouldShowName() {
return false;
}

Expand Down
23 changes: 11 additions & 12 deletions src/main/java/org/purpurmc/purpur/client/gui/SplashTexture.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
package org.purpurmc.purpur.client.gui;

import net.minecraft.client.resource.metadata.TextureResourceMetadata;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.ResourceTexture;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import org.purpurmc.purpur.client.PurpurClient;

import com.mojang.blaze3d.platform.NativeImage;
import java.io.IOException;
import java.io.InputStream;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.resources.metadata.texture.TextureMetadataSection;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;

public class SplashTexture extends ResourceTexture {
public static final Identifier SPLASH = new Identifier("purpurclient", "textures/splash.png");
public class SplashTexture extends SimpleTexture {
public static final ResourceLocation SPLASH = new ResourceLocation("purpurclient", "textures/splash.png");

public SplashTexture() {
super(SPLASH);
}

@Override
protected TextureData loadTextureData(ResourceManager resourceManager) {
TextureData data;
protected TextureImage getTextureImage(ResourceManager resourceManager) {
TextureImage data;
try (InputStream in = PurpurClient.class.getResourceAsStream("/assets/purpurclient/textures/splash.png")) {
data = new TextureData(new TextureResourceMetadata(true, true), NativeImage.read(in));
data = new TextureImage(new TextureMetadataSection(true, true), NativeImage.read(in));
} catch (IOException e) {
return new TextureData(e);
return new TextureImage(e);
}
return data;
}
Expand Down
Loading

0 comments on commit f3143ff

Please sign in to comment.