Skip to content

Commit

Permalink
target 1.20.5-pre1
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Apr 14, 2024
1 parent fcd54dc commit 452c713
Show file tree
Hide file tree
Showing 77 changed files with 787 additions and 994 deletions.
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
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
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
fabricLoader = 0.15.9
fabricApi = 0.96.15+1.20.5
modMenu = 9.0.0-pre.1
trEnergy = 3.0.0

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
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,7 +44,7 @@ public Fluid fluid(FluidVariant t) {
}

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

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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.mojang.blaze3d.vertex.BufferBuilder;
import mcp.mobius.waila.api.IBlacklistConfig;
import mcp.mobius.waila.api.IData;
import mcp.mobius.waila.api.IInstanceRegistry;
import mcp.mobius.waila.api.IJsonConfig;
import mcp.mobius.waila.api.IModInfo;
Expand Down Expand Up @@ -79,4 +80,6 @@ public interface IApiService {

List<Tier> getTiers();

<D extends IData> IData.Type<D> createDataType(ResourceLocation id);

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public final class BlockingDataProvider<T> implements IDataProvider<T> {
* @param types data types to block
*/
@SafeVarargs
public BlockingDataProvider(Class<? extends IData>... types) {
public BlockingDataProvider(IData.Type<? extends IData>... types) {
this.types = types;
}

private final Class<? extends IData>[] types;
private final IData.Type<? extends IData>[] types;

@Override
public void appendData(IDataWriter data, IServerAccessor<T> accessor, IPluginConfig config) {
Expand Down
3 changes: 2 additions & 1 deletion src/api/java/mcp/mobius/waila/api/data/EnergyData.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
public abstract class EnergyData implements IData {

public static final ResourceLocation ID = BuiltinDataUtil.rl("energy");
public static final Type<EnergyData> TYPE = IData.createType(ID);

/**
* The default energy name translation key.
Expand Down Expand Up @@ -55,7 +56,7 @@ public abstract class EnergyData implements IData {
* @see #INFINITE
*/
public static <T> IDataProvider<T> newInfiniteProvider() {
return (data, accessor, config) -> data.add(EnergyData.class, res -> res.add(INFINITE));
return (data, accessor, config) -> data.add(TYPE, res -> res.add(INFINITE));
}

/**
Expand Down
Loading

0 comments on commit 452c713

Please sign in to comment.