Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target 1.20.5-pre1 #254

Merged
merged 5 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
python-version: 3.x
- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: temurin
- uses: gradle/gradle-build-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/head.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: temurin
- uses: gradle/gradle-build-action@v2
with:
Expand Down
9 changes: 5 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,21 @@ allprojects {
}

mavenCentral()
maven("https://maven-staging.bai.lol")
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
toolchain.languageVersion.set(JavaLanguageVersion.of(21))

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

withSourcesJar()
}

tasks.withType<JavaCompile> {
options.encoding = StandardCharsets.UTF_8.name()
options.release.set(17)
options.release.set(21)
}

tasks.withType<ProcessResources> {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
implementation("de.undercouch:gradle-download-task:5.0.5")

implementation("com.squareup:javapoet:1.13.0")
implementation("com.google.code.gson:gson:2.9.0")
implementation("com.google.code.gson:gson:2.10.1")
implementation("com.google.guava:guava:31.0.1-jre")

// https://github.com/MinecraftForge/ForgeGradle/issues/919
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
org.gradle.jvmargs = -Xmx3G

minecraft = 1.20.4
minecraft = 1.20.5-pre1

archiveBaseName = wthit
group = mcp.mobius.waila
majorVersion = 10
majorVersion = 11

# [rei, jei, emi]
recipeViewer = none

badpackets = 0.6.0
badpackets = 0.7.0-git-655fa14a
rei = 13.0.666
jei = 1.20.2-16.0.0.28
emi = 1.0.23+1.20.2

fabricLoader = 0.15.2
fabricApi = 0.91.3+1.20.4
modMenu = 9.0.0-pre.1
fabricLoader = 0.15.9
fabricApi = 0.96.15+1.20.5
modMenu = 10.0.0-alpha.3
trEnergy = 3.0.0

forge = 49.0.9
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase = GRADLE_USER_HOME
distributionPath = wrapper/dists
zipStoreBase = GRADLE_USER_HOME
zipStorePath = wrapper/dists
distributionUrl = https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl = https\://services.gradle.org/distributions/gradle-8.7-bin.zip
2 changes: 1 addition & 1 deletion platform/fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
evaluationDependsOn(":textile")

plugins {
id("fabric-loom") version "1.3.10"
id("fabric-loom") version "1.6.6"
}

setupPlatform()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
package mcp.mobius.waila.fabric;

import mcp.mobius.waila.service.ApiService;
import net.fabricmc.fabric.api.mininglevel.v1.MiningLevelManager;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Tier;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.Nullable;

public class FabricApiService extends ApiService {

@Override
public @Nullable TagKey<Block> getTierTag(Tier tier) {
return tier.getLevel() == 0 ? null : MiningLevelManager.getBlockTag(tier.getLevel());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Optional;

import mcp.mobius.waila.api.IPluginInfo;
import mcp.mobius.waila.api.WailaConstants;
import mcp.mobius.waila.service.ICommonService;
import mcp.mobius.waila.util.ModInfo;
import net.fabricmc.loader.api.FabricLoader;
Expand Down Expand Up @@ -46,4 +47,10 @@ public IPluginInfo.Side getSide() {
};
}

@Override
@SuppressWarnings("OptionalGetWithoutIsPresent")
public String getIssueUrl() {
return FabricLoader.getInstance().getModContainer(WailaConstants.MOD_ID).get().getMetadata().getContact().get("issues").get();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void onInitializeClient() {

HudRenderCallback.EVENT.register(TooltipRenderer::render);
ClientTickEvents.END_CLIENT_TICK.register(client -> onClientTick());
ItemTooltipCallback.EVENT.register((stack, ctx, tooltip) -> onItemTooltip(stack, tooltip));
ItemTooltipCallback.EVENT.register((stack, ctx, flag, tooltip) -> onItemTooltip(stack, tooltip));

ClientConfigurationConnectionEvents.DISCONNECT.register((handler, client) -> client.execute(WailaClient::onServerLogout));
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> client.execute(WailaClient::onServerLogout));
Expand Down
2 changes: 1 addition & 1 deletion platform/textile/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("fabric-loom") version "1.3.10"
id("fabric-loom") version "1.6.6"
}

setupPlatform()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import mcp.mobius.waila.api.data.FluidData.PlatformDependant;
import mcp.mobius.waila.api.data.FluidData.PlatformTranslator;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.world.level.material.Fluid;
import org.jetbrains.annotations.Nullable;

/**
* Fabric-specific helper for creating {@link FluidData}.
Expand Down Expand Up @@ -45,8 +44,8 @@ public Fluid fluid(FluidVariant t) {
}

@Override
public @Nullable CompoundTag nbt(FluidVariant t) {
return t.getNbt();
public DataComponentPatch data(FluidVariant t) {
return t.getComponents();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import mcp.mobius.waila.plugin.textile.fluid.TextileFluidDescriptor;
import mcp.mobius.waila.plugin.textile.provider.FluidStorageProvider;
import mcp.mobius.waila.plugin.textile.provider.ItemStorageProvider;
import net.fabricmc.fabric.api.mininglevel.v1.FabricMineableTags;
import net.fabricmc.fabric.api.tag.convention.v1.ConventionalItemTags;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
Expand Down Expand Up @@ -54,13 +53,14 @@ public void register(IRegistrar registrar) {

registrar.addToolType(new ResourceLocation("sword"), IToolType.builder()
.lowestTierItem(Items.WOODEN_SWORD)
.blockTag(FabricMineableTags.SWORD_MINEABLE)
.blockTag(BlockTags.SWORD_EFFICIENT)
.itemTag(ItemTags.SWORDS)
.build());

// TODO
registrar.addToolType(new ResourceLocation("shears"), IToolType.builder()
.lowestTierItem(Items.SHEARS)
.blockPredicate(it -> it.is(FabricMineableTags.SHEARS_MINEABLE) || it.getBlock() instanceof IShearable || it.getBlock() instanceof DoublePlantBlock)
.blockPredicate(it -> /*it.is(BlockTags.SHEARS_MINEABLE) ||*/ it.getBlock() instanceof IShearable || it.getBlock() instanceof DoublePlantBlock)
.itemTag(ConventionalItemTags.SHEARS)
.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum TextileFluidDescriptor implements FluidDescriptor<Fluid>, CauldronDe

@Override
public void describeFluid(FluidDescriptionContext<Fluid> ctx, FluidDescription desc) {
var variant = FluidVariant.of(ctx.fluid(), ctx.nbt());
var variant = FluidVariant.of(ctx.fluid(), ctx.data());
desc.name(FluidVariantAttributes.getName(variant));

var sprite = FluidVariantRendering.getSprite(variant);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public enum FluidStorageProvider implements IDataProvider<BlockEntity> {

@Override
public void appendData(IDataWriter data, IServerAccessor<BlockEntity> accessor, IPluginConfig config) {
data.add(FluidData.class, res -> {
data.add(FluidData.TYPE, res -> {
if (cache == null || cache.getBlockEntity() != accessor.getTarget()) {
cache = BlockApiCache.create(FluidStorage.SIDED, (ServerLevel) accessor.getWorld(), accessor.getTarget().getBlockPos());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public enum ItemStorageProvider implements IDataProvider<BlockEntity> {

@Override
public void appendData(IDataWriter data, IServerAccessor<BlockEntity> accessor, IPluginConfig config) {
data.add(ItemData.class, res -> {
data.add(ItemData.TYPE, res -> {
if (cache == null || cache.getBlockEntity() != accessor.getTarget()) {
cache = BlockApiCache.create(ItemStorage.SIDED, (ServerLevel) accessor.getWorld(), accessor.getTarget().getBlockPos());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum EnergyStorageProvider implements IDataProvider<BlockEntity> {

@Override
public void appendData(IDataWriter data, IServerAccessor<BlockEntity> accessor, IPluginConfig config) {
data.add(EnergyData.class, res -> {
data.add(EnergyData.TYPE, res -> {
if (cache == null || cache.getBlockEntity() != accessor.getTarget()) {
cache = BlockApiCache.create(EnergyStorage.SIDED, (ServerLevel) accessor.getWorld(), accessor.getTarget().getBlockPos());
}
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ platform("mojmap")

//platform("bukkit")
platform("fabric")
platform("forge")
platform("neo")
//platform("forge")
//platform("neo")
platform("textile")
//platform("quilt")
39 changes: 23 additions & 16 deletions src/api/java/mcp/mobius/waila/api/IData.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mcp.mobius.waila.api;

import net.minecraft.network.FriendlyByteBuf;
import mcp.mobius.waila.api.__internal__.IApiService;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.ApiStatus;

/**
Expand All @@ -16,26 +17,32 @@
public interface IData {

/**
* Write current data to the buffer.
* Creates a data type.
* <p>
* Save the returned value to a static final variable.
*
* @param buf the buffer
* @param id the data id
*/
@ApiStatus.OverrideOnly
void write(FriendlyByteBuf buf);
static <D extends IData> Type<D> createType(ResourceLocation id) {
return IApiService.INSTANCE.createDataType(id);
}

/**
* A byte buffer to data serializer, should be implemented as a reference to data constructor.
* Returns the type of the data, should be a constant variable.
*
* @see #createType(ResourceLocation)
*/
@FunctionalInterface
@ApiStatus.OverrideOnly
interface Serializer<T extends IData> {

/**
* Read data from the buffer.
*
* @param buf the buffer
*/
T read(FriendlyByteBuf buf);
Type<? extends IData> type();


/**
* @see #createType(ResourceLocation)
*/
@SuppressWarnings("unused")
@ApiStatus.NonExtendable
interface Type<D extends IData> {

ResourceLocation id();

}

Expand Down
8 changes: 4 additions & 4 deletions src/api/java/mcp/mobius/waila/api/IDataReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public interface IDataReader {
*
* @param type the type of the data.
*/
@Nullable <T extends IData> T get(Class<T> type);
@Nullable <D extends IData> D get(IData.Type<D> type);

/**
* Invalidate the current data instance of type {@code T},
* making {@link #get(Class)} returns {@code null} until a new instance is synced.
* Invalidate the current data instance of type {@code D},
* making {@link #get(IData.Type)} returns {@code null} until a new instance is synced.
*
* @param type the type of the data
*/
<T extends IData> void invalidate(Class<T> type);
<D extends IData> void invalidate(IData.Type<D> type);

}
8 changes: 4 additions & 4 deletions src/api/java/mcp/mobius/waila/api/IDataWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ public interface IDataWriter {
*
* @see IData
*/
<T extends IData> void add(Class<T> type, Consumer<Result<T>> consumer);
<D extends IData> void add(IData.Type<D> type, Consumer<Result<D>> consumer);

/**
* Immediately adds a typed data.
* <p>
* Use this method only for internal data that only you use, otherwise use {@link #add(Class, Consumer)} instead.
* Use this method only for internal data that only you use, otherwise use {@link #add(IData.Type, Consumer)} instead.
*
* @param data the data to add
*
* @throws IllegalStateException if the data is already added, whether with {@link #add(Class, Consumer)} or this method
* @throws IllegalStateException if the data is already added, whether with {@link #add(IData.Type, Consumer)} or this method
*/
void addImmediate(IData data);

Expand All @@ -51,7 +51,7 @@ public interface IDataWriter {
*
* @param type the type of the data that wanted to be blocked
*/
default void blockAll(Class<? extends IData> type) {
default void blockAll(IData.Type<? extends IData> type) {
add(type, Result::block);
}

Expand Down
21 changes: 5 additions & 16 deletions src/api/java/mcp/mobius/waila/api/IRegistrar.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import mcp.mobius.waila.api.__internal__.ApiSide;
import mcp.mobius.waila.api.__internal__.IHarvestService;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
Expand Down Expand Up @@ -601,23 +603,10 @@ default <T, E extends Entity> void addEntityData(IDataProvider<E> provider, Clas
/**
* Registers a data type used for syncing data from server to client.
*
* @param id the id of the data type
* @param apiType the public type of data, to be used when {@linkplain IDataReader#get(Class) getting} it
* @param implType the actual type of data that get sent
* @param serializer the data to buffer serializer
* @param type the data type
* @param codec the data-to-buffer codec
*/
<A extends IData, I extends A> void addDataType(ResourceLocation id, Class<A> apiType, Class<I> implType, IData.Serializer<I> serializer);

/**
* Registers a data type used for syncing data from server to client.
*
* @param id the id of the data type
* @param type the type of data
* @param serializer the data to buffer serializer
*/
default <T extends IData> void addDataType(ResourceLocation id, Class<T> type, IData.Serializer<T> serializer) {
addDataType(id, type, type, serializer);
}
<D extends IData> void addDataType(IData.Type<D> type, StreamCodec<? super RegistryFriendlyByteBuf, ? extends D> codec);

/**
* Registers an {@link IThemeType} instance.
Expand Down
Loading
Loading