diff --git a/build.gradle b/build.gradle index f0d23bd6..9e2553af 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { - id "architectury-plugin" version "3.0.97" - id "forgified-fabric-loom" version "0.6.78" apply false + id "architectury-plugin" version "3.1-SNAPSHOT" + id "forgified-fabric-loom" version "0.6-SNAPSHOT" apply false id "org.cadixdev.licenser" version "0.5.0" id "com.matthewprenger.cursegradle" version "1.4.0" apply false id "maven-publish" diff --git a/common/src/main/java/me/shedaniel/architectury/Architectury.java b/common/src/main/java/me/shedaniel/architectury/Architectury.java index ce0c85a7..9d19f01f 100644 --- a/common/src/main/java/me/shedaniel/architectury/Architectury.java +++ b/common/src/main/java/me/shedaniel/architectury/Architectury.java @@ -19,39 +19,14 @@ package me.shedaniel.architectury; -import com.google.common.collect.ImmutableMap; -import org.apache.logging.log4j.LogManager; +import me.shedaniel.architectury.targets.ArchitecturyTarget; import org.jetbrains.annotations.ApiStatus; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - @ApiStatus.Internal public class Architectury { - private static final String MOD_LOADER; - private static final ImmutableMap MOD_LOADERS = ImmutableMap.builder() - .put("net.fabricmc.loader.FabricLoader", "fabric") - .put("net.minecraftforge.fml.common.Mod", "forge") - .build(); - + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.0") public static String getModLoader() { - return MOD_LOADER; - } - - static { - List loader = new ArrayList<>(); - for (Map.Entry entry : MOD_LOADERS.entrySet()) { - try { - Class.forName(entry.getKey(), false, Architectury.class.getClassLoader()); - loader.add(entry.getValue()); - break; - } catch (ClassNotFoundException ignored) {} - } - if (loader.isEmpty()) - throw new IllegalStateException("No detected mod loader!"); - if (loader.size() >= 2) - LogManager.getLogger().error("Detected multiple mod loaders! Something is wrong on the classpath! " + String.join(", ", loader)); - MOD_LOADER = loader.get(0); + return ArchitecturyTarget.getCurrentTarget(); } } diff --git a/common/src/main/java/me/shedaniel/architectury/event/events/ChatEvent.java b/common/src/main/java/me/shedaniel/architectury/event/events/ChatEvent.java index accdacd3..72c6908f 100644 --- a/common/src/main/java/me/shedaniel/architectury/event/events/ChatEvent.java +++ b/common/src/main/java/me/shedaniel/architectury/event/events/ChatEvent.java @@ -26,7 +26,6 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.TextFilter; import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResultHolder; -import org.jetbrains.annotations.NotNull; public interface ChatEvent { /** @@ -35,7 +34,6 @@ public interface ChatEvent { Event SERVER = EventFactory.createInteractionResultHolder(); interface Server { - @NotNull InteractionResult process(ServerPlayer player, TextFilter.FilteredText message, ChatComponent component); } diff --git a/common/src/main/java/me/shedaniel/architectury/event/events/CommandPerformEvent.java b/common/src/main/java/me/shedaniel/architectury/event/events/CommandPerformEvent.java index 3664e7e5..5e505df0 100644 --- a/common/src/main/java/me/shedaniel/architectury/event/events/CommandPerformEvent.java +++ b/common/src/main/java/me/shedaniel/architectury/event/events/CommandPerformEvent.java @@ -24,7 +24,6 @@ import me.shedaniel.architectury.event.Actor; import me.shedaniel.architectury.event.Event; import me.shedaniel.architectury.event.EventFactory; import net.minecraft.commands.CommandSourceStack; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class CommandPerformEvent { @@ -33,22 +32,20 @@ public class CommandPerformEvent { */ public static final Event> EVENT = EventFactory.createActorLoop(); - @NotNull private ParseResults results; @Nullable private Throwable throwable; - public CommandPerformEvent(@NotNull ParseResults results, @Nullable Throwable throwable) { + public CommandPerformEvent(ParseResults results, @Nullable Throwable throwable) { this.results = results; this.throwable = throwable; } - @NotNull public ParseResults getResults() { return results; } - public void setResults(@NotNull ParseResults results) { + public void setResults(ParseResults results) { this.results = results; } diff --git a/common/src/main/java/me/shedaniel/architectury/event/events/client/ClientChatEvent.java b/common/src/main/java/me/shedaniel/architectury/event/events/client/ClientChatEvent.java index 5c35146d..fef7ae3d 100644 --- a/common/src/main/java/me/shedaniel/architectury/event/events/client/ClientChatEvent.java +++ b/common/src/main/java/me/shedaniel/architectury/event/events/client/ClientChatEvent.java @@ -26,7 +26,6 @@ import net.fabricmc.api.Environment; import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionResultHolder; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.UUID; @@ -44,13 +43,11 @@ public interface ClientChatEvent { @Environment(EnvType.CLIENT) interface Client { - @NotNull InteractionResultHolder process(String message); } @Environment(EnvType.CLIENT) interface ClientReceived { - @NotNull InteractionResultHolder process(ChatType type, Component message, @Nullable UUID sender); } } diff --git a/common/src/main/java/me/shedaniel/architectury/event/events/client/ClientLifecycleEvent.java b/common/src/main/java/me/shedaniel/architectury/event/events/client/ClientLifecycleEvent.java index 999ebf07..86ed4bc9 100644 --- a/common/src/main/java/me/shedaniel/architectury/event/events/client/ClientLifecycleEvent.java +++ b/common/src/main/java/me/shedaniel/architectury/event/events/client/ClientLifecycleEvent.java @@ -34,7 +34,7 @@ public interface ClientLifecycleEvent { */ @Deprecated Event CLIENT_STARTED = EventFactory.createLoop(); /** - * Invoked when client is initialising, not available in forge. + * Invoked when client is stopping, not available in forge. */ @Deprecated Event CLIENT_STOPPING = EventFactory.createLoop(); /** diff --git a/common/src/main/java/me/shedaniel/architectury/extensions/BlockEntityExtension.java b/common/src/main/java/me/shedaniel/architectury/extensions/BlockEntityExtension.java index ab84b386..0f2f12bc 100644 --- a/common/src/main/java/me/shedaniel/architectury/extensions/BlockEntityExtension.java +++ b/common/src/main/java/me/shedaniel/architectury/extensions/BlockEntityExtension.java @@ -26,7 +26,6 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; /** * Extensions to {@link net.minecraft.world.level.block.entity.BlockEntity}, implement this on to your class. @@ -36,13 +35,12 @@ public interface BlockEntityExtension { * Handles data sent by {@link BlockEntityExtension#saveClientData(CompoundTag)} on the server. */ @Environment(EnvType.CLIENT) - void loadClientData(@NotNull BlockState pos, @NotNull CompoundTag tag); + void loadClientData(BlockState pos, CompoundTag tag); /** * Writes data to sync to the client. */ - @NotNull - CompoundTag saveClientData(@NotNull CompoundTag tag); + CompoundTag saveClientData(CompoundTag tag); /** * Sync data to the clients by {@link BlockEntityExtension#saveClientData(CompoundTag)} and {@link BlockEntityExtension#loadClientData(BlockState, CompoundTag)}. diff --git a/common/src/main/java/me/shedaniel/architectury/hooks/FluidStackHooks.java b/common/src/main/java/me/shedaniel/architectury/hooks/FluidStackHooks.java index 2ebc0f8d..d170a611 100644 --- a/common/src/main/java/me/shedaniel/architectury/hooks/FluidStackHooks.java +++ b/common/src/main/java/me/shedaniel/architectury/hooks/FluidStackHooks.java @@ -31,7 +31,6 @@ import net.minecraft.network.chat.Component; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class FluidStackHooks { @@ -92,60 +91,60 @@ public class FluidStackHooks { @ExpectPlatform @Environment(EnvType.CLIENT) @Nullable - public static TextureAtlasSprite getStillTexture(@Nullable BlockAndTintGetter level, @Nullable BlockPos pos, @NotNull FluidState state) { + public static TextureAtlasSprite getStillTexture(@Nullable BlockAndTintGetter level, @Nullable BlockPos pos, FluidState state) { throw new AssertionError(); } @ExpectPlatform @Environment(EnvType.CLIENT) @Nullable - public static TextureAtlasSprite getStillTexture(@NotNull FluidStack stack) { + public static TextureAtlasSprite getStillTexture(FluidStack stack) { throw new AssertionError(); } @ExpectPlatform @Environment(EnvType.CLIENT) @Nullable - public static TextureAtlasSprite getStillTexture(@NotNull Fluid fluid) { + public static TextureAtlasSprite getStillTexture(Fluid fluid) { throw new AssertionError(); } @ExpectPlatform @Environment(EnvType.CLIENT) @Nullable - public static TextureAtlasSprite getFlowingTexture(@Nullable BlockAndTintGetter level, @Nullable BlockPos pos, @NotNull FluidState state) { + public static TextureAtlasSprite getFlowingTexture(@Nullable BlockAndTintGetter level, @Nullable BlockPos pos, FluidState state) { throw new AssertionError(); } @ExpectPlatform @Environment(EnvType.CLIENT) @Nullable - public static TextureAtlasSprite getFlowingTexture(@NotNull FluidStack stack) { + public static TextureAtlasSprite getFlowingTexture(FluidStack stack) { throw new AssertionError(); } @ExpectPlatform @Environment(EnvType.CLIENT) @Nullable - public static TextureAtlasSprite getFlowingTexture(@NotNull Fluid fluid) { + public static TextureAtlasSprite getFlowingTexture(Fluid fluid) { throw new AssertionError(); } @ExpectPlatform @Environment(EnvType.CLIENT) - public static int getColor(@Nullable BlockAndTintGetter level, @Nullable BlockPos pos, @NotNull FluidState state) { + public static int getColor(@Nullable BlockAndTintGetter level, @Nullable BlockPos pos, FluidState state) { throw new AssertionError(); } @ExpectPlatform @Environment(EnvType.CLIENT) - public static int getColor(@NotNull FluidStack stack) { + public static int getColor(FluidStack stack) { throw new AssertionError(); } @ExpectPlatform @Environment(EnvType.CLIENT) - public static int getColor(@NotNull Fluid fluid) { + public static int getColor(Fluid fluid) { throw new AssertionError(); } } diff --git a/common/src/main/java/me/shedaniel/architectury/hooks/biome/BiomeHooks.java b/common/src/main/java/me/shedaniel/architectury/hooks/biome/BiomeHooks.java index ef4b4543..a3e38746 100644 --- a/common/src/main/java/me/shedaniel/architectury/hooks/biome/BiomeHooks.java +++ b/common/src/main/java/me/shedaniel/architectury/hooks/biome/BiomeHooks.java @@ -41,7 +41,6 @@ import java.util.OptionalInt; import java.util.function.Supplier; public final class BiomeHooks { - @NotNull public static BiomeProperties getBiomeProperties(Biome biome) { return new BiomeWrapped(biome); } @@ -74,31 +73,26 @@ public final class BiomeHooks { } @Override - @NotNull public ClimateProperties getClimateProperties() { return climateProperties; } @Override - @NotNull public EffectsProperties getEffectsProperties() { return effectsProperties; } - @NotNull @Override public GenerationProperties getGenerationProperties() { return generationProperties; } - @NotNull @Override public SpawnProperties getSpawnProperties() { return spawnProperties; } @Override - @NotNull public BiomeCategory getCategory() { return biome.biomeCategory; } @@ -138,41 +132,38 @@ public final class BiomeHooks { } @Override - public @NotNull ClimateProperties.Mutable getClimateProperties() { + public ClimateProperties.Mutable getClimateProperties() { return (ClimateProperties.Mutable) super.getClimateProperties(); } @Override - public @NotNull EffectsProperties.Mutable getEffectsProperties() { + public EffectsProperties.Mutable getEffectsProperties() { return (EffectsProperties.Mutable) super.getEffectsProperties(); } @Override - public @NotNull GenerationProperties.Mutable getGenerationProperties() { + public GenerationProperties.Mutable getGenerationProperties() { return (GenerationProperties.Mutable) super.getGenerationProperties(); } @Override - public @NotNull SpawnProperties.Mutable getSpawnProperties() { + public SpawnProperties.Mutable getSpawnProperties() { return (SpawnProperties.Mutable) super.getSpawnProperties(); } @Override - @NotNull - public Mutable setCategory(@NotNull BiomeCategory category) { + public Mutable setCategory(BiomeCategory category) { biome.biomeCategory = category; return this; } @Override - @NotNull public Mutable setDepth(float depth) { biome.depth = depth; return this; } @Override - @NotNull public Mutable setScale(float scale) { biome.scale = scale; return this; @@ -191,35 +182,30 @@ public final class BiomeHooks { } @Override - @NotNull - public Mutable setPrecipitation(@NotNull Biome.Precipitation precipitation) { + public Mutable setPrecipitation(Biome.Precipitation precipitation) { climateSettings.precipitation = precipitation; return this; } @Override - @NotNull public Mutable setTemperature(float temperature) { climateSettings.temperature = temperature; return this; } @Override - @NotNull - public Mutable setTemperatureModifier(@NotNull Biome.TemperatureModifier temperatureModifier) { + public Mutable setTemperatureModifier(Biome.TemperatureModifier temperatureModifier) { climateSettings.temperatureModifier = temperatureModifier; return this; } @Override - @NotNull public Mutable setDownfall(float downfall) { climateSettings.downfall = downfall; return this; } @Override - @NotNull public Biome.Precipitation getPrecipitation() { return climateSettings.precipitation; } @@ -230,7 +216,6 @@ public final class BiomeHooks { } @Override - @NotNull public Biome.TemperatureModifier getTemperatureModifier() { return climateSettings.temperatureModifier; } @@ -253,84 +238,72 @@ public final class BiomeHooks { } @Override - @NotNull public EffectsProperties.Mutable setFogColor(int color) { effects.fogColor = color; return this; } @Override - @NotNull public EffectsProperties.Mutable setWaterColor(int color) { effects.waterColor = color; return this; } @Override - @NotNull public EffectsProperties.Mutable setWaterFogColor(int color) { effects.waterFogColor = color; return this; } @Override - @NotNull public EffectsProperties.Mutable setSkyColor(int color) { effects.skyColor = color; return this; } @Override - @NotNull public EffectsProperties.Mutable setFoliageColorOverride(@Nullable Integer colorOverride) { effects.foliageColorOverride = Optional.ofNullable(colorOverride); return this; } @Override - @NotNull public EffectsProperties.Mutable setGrassColorOverride(@Nullable Integer colorOverride) { effects.grassColorOverride = Optional.ofNullable(colorOverride); return this; } @Override - @NotNull - public EffectsProperties.Mutable setGrassColorModifier(@NotNull GrassColorModifier modifier) { + public EffectsProperties.Mutable setGrassColorModifier(GrassColorModifier modifier) { effects.grassColorModifier = modifier; return this; } @Override - @NotNull public EffectsProperties.Mutable setAmbientParticle(@Nullable AmbientParticleSettings settings) { effects.ambientParticleSettings = Optional.ofNullable(settings); return this; } @Override - @NotNull public EffectsProperties.Mutable setAmbientLoopSound(@Nullable SoundEvent sound) { effects.ambientLoopSoundEvent = Optional.ofNullable(sound); return this; } @Override - @NotNull public EffectsProperties.Mutable setAmbientMoodSound(@Nullable AmbientMoodSettings settings) { effects.ambientMoodSettings = Optional.ofNullable(settings); return this; } @Override - @NotNull public EffectsProperties.Mutable setAmbientAdditionsSound(@Nullable AmbientAdditionsSettings settings) { effects.ambientAdditionsSettings = Optional.ofNullable(settings); return this; } @Override - @NotNull public EffectsProperties.Mutable setBackgroundMusic(@Nullable Music music) { effects.backgroundMusic = Optional.ofNullable(music); return this; @@ -357,49 +330,41 @@ public final class BiomeHooks { } @Override - @NotNull public OptionalInt getFoliageColorOverride() { return effects.foliageColorOverride.map(OptionalInt::of).orElseGet(OptionalInt::empty); } @Override - @NotNull public OptionalInt getGrassColorOverride() { return effects.grassColorOverride.map(OptionalInt::of).orElseGet(OptionalInt::empty); } @Override - @NotNull public GrassColorModifier getGrassColorModifier() { return effects.grassColorModifier; } @Override - @NotNull public Optional getAmbientParticle() { return effects.ambientParticleSettings; } @Override - @NotNull public Optional getAmbientLoopSound() { return effects.ambientLoopSoundEvent; } @Override - @NotNull public Optional getAmbientMoodSound() { return effects.ambientMoodSettings; } @Override - @NotNull public Optional getAmbientAdditionsSound() { return effects.ambientAdditionsSettings; } @Override - @NotNull public Optional getBackgroundMusic() { return effects.backgroundMusic; } @@ -417,22 +382,22 @@ public final class BiomeHooks { } @Override - public @NotNull Optional>> getSurfaceBuilder() { + public Optional>> getSurfaceBuilder() { return Optional.ofNullable(settings.getSurfaceBuilder()); } @Override - public @NotNull List>> getCarvers(GenerationStep.Carving carving) { + public List>> getCarvers(GenerationStep.Carving carving) { return settings.getCarvers(carving); } @Override - public @NotNull List>>> getFeatures() { + public List>>> getFeatures() { return settings.features(); } @Override - public @NotNull List>> getStructureStarts() { + public List>> getStructureStarts() { return (List>>) settings.structures(); } } @@ -454,13 +419,11 @@ public final class BiomeHooks { } @Override - @NotNull public Map> getSpawners() { return null; } @Override - @NotNull public Map, MobSpawnSettings.MobSpawnCost> getMobSpawnCosts() { return null; } diff --git a/common/src/main/java/me/shedaniel/architectury/hooks/biome/BiomeProperties.java b/common/src/main/java/me/shedaniel/architectury/hooks/biome/BiomeProperties.java index 45b02374..fcba9cf0 100644 --- a/common/src/main/java/me/shedaniel/architectury/hooks/biome/BiomeProperties.java +++ b/common/src/main/java/me/shedaniel/architectury/hooks/biome/BiomeProperties.java @@ -20,22 +20,16 @@ package me.shedaniel.architectury.hooks.biome; import net.minecraft.world.level.biome.Biome.BiomeCategory; -import org.jetbrains.annotations.NotNull; public interface BiomeProperties { - @NotNull ClimateProperties getClimateProperties(); - @NotNull EffectsProperties getEffectsProperties(); - @NotNull GenerationProperties getGenerationProperties(); - @NotNull SpawnProperties getSpawnProperties(); - @NotNull BiomeCategory getCategory(); float getDepth(); @@ -44,28 +38,21 @@ public interface BiomeProperties { interface Mutable extends BiomeProperties { @Override - @NotNull ClimateProperties.Mutable getClimateProperties(); @Override - @NotNull EffectsProperties.Mutable getEffectsProperties(); @Override - @NotNull GenerationProperties.Mutable getGenerationProperties(); @Override - @NotNull SpawnProperties.Mutable getSpawnProperties(); - @NotNull - Mutable setCategory(@NotNull BiomeCategory category); + Mutable setCategory(BiomeCategory category); - @NotNull Mutable setDepth(float depth); - @NotNull Mutable setScale(float scale); } -} \ No newline at end of file +} diff --git a/common/src/main/java/me/shedaniel/architectury/hooks/biome/ClimateProperties.java b/common/src/main/java/me/shedaniel/architectury/hooks/biome/ClimateProperties.java index e35cf16f..218572df 100644 --- a/common/src/main/java/me/shedaniel/architectury/hooks/biome/ClimateProperties.java +++ b/common/src/main/java/me/shedaniel/architectury/hooks/biome/ClimateProperties.java @@ -24,27 +24,21 @@ import net.minecraft.world.level.biome.Biome.TemperatureModifier; import org.jetbrains.annotations.NotNull; public interface ClimateProperties { - @NotNull Precipitation getPrecipitation(); float getTemperature(); - @NotNull TemperatureModifier getTemperatureModifier(); float getDownfall(); interface Mutable extends ClimateProperties { - @NotNull - Mutable setPrecipitation(@NotNull Precipitation precipitation); + Mutable setPrecipitation(Precipitation precipitation); - @NotNull Mutable setTemperature(float temperature); - @NotNull - Mutable setTemperatureModifier(@NotNull TemperatureModifier temperatureModifier); + Mutable setTemperatureModifier(TemperatureModifier temperatureModifier); - @NotNull Mutable setDownfall(float downfall); } -} \ No newline at end of file +} diff --git a/common/src/main/java/me/shedaniel/architectury/hooks/biome/EffectsProperties.java b/common/src/main/java/me/shedaniel/architectury/hooks/biome/EffectsProperties.java index b6f807a0..875c1a23 100644 --- a/common/src/main/java/me/shedaniel/architectury/hooks/biome/EffectsProperties.java +++ b/common/src/main/java/me/shedaniel/architectury/hooks/biome/EffectsProperties.java @@ -25,7 +25,6 @@ import net.minecraft.world.level.biome.AmbientAdditionsSettings; import net.minecraft.world.level.biome.AmbientMoodSettings; import net.minecraft.world.level.biome.AmbientParticleSettings; import net.minecraft.world.level.biome.BiomeSpecialEffects.GrassColorModifier; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Optional; @@ -40,65 +39,45 @@ public interface EffectsProperties { int getSkyColor(); - @NotNull OptionalInt getFoliageColorOverride(); - @NotNull OptionalInt getGrassColorOverride(); - @NotNull GrassColorModifier getGrassColorModifier(); - @NotNull Optional getAmbientParticle(); - @NotNull Optional getAmbientLoopSound(); - @NotNull Optional getAmbientMoodSound(); - @NotNull Optional getAmbientAdditionsSound(); - @NotNull Optional getBackgroundMusic(); interface Mutable extends EffectsProperties { - @NotNull EffectsProperties.Mutable setFogColor(int color); - @NotNull EffectsProperties.Mutable setWaterColor(int color); - @NotNull EffectsProperties.Mutable setWaterFogColor(int color); - @NotNull EffectsProperties.Mutable setSkyColor(int color); - @NotNull EffectsProperties.Mutable setFoliageColorOverride(@Nullable Integer colorOverride); - @NotNull EffectsProperties.Mutable setGrassColorOverride(@Nullable Integer colorOverride); - @NotNull - EffectsProperties.Mutable setGrassColorModifier(@NotNull GrassColorModifier modifier); + EffectsProperties.Mutable setGrassColorModifier(GrassColorModifier modifier); - @NotNull EffectsProperties.Mutable setAmbientParticle(@Nullable AmbientParticleSettings settings); - @NotNull EffectsProperties.Mutable setAmbientLoopSound(@Nullable SoundEvent sound); - @NotNull EffectsProperties.Mutable setAmbientMoodSound(@Nullable AmbientMoodSettings settings); - @NotNull EffectsProperties.Mutable setAmbientAdditionsSound(@Nullable AmbientAdditionsSettings settings); - @NotNull EffectsProperties.Mutable setBackgroundMusic(@Nullable Music music); } -} \ No newline at end of file +} diff --git a/common/src/main/java/me/shedaniel/architectury/hooks/biome/GenerationProperties.java b/common/src/main/java/me/shedaniel/architectury/hooks/biome/GenerationProperties.java index 78e3fd34..a8bc6fad 100644 --- a/common/src/main/java/me/shedaniel/architectury/hooks/biome/GenerationProperties.java +++ b/common/src/main/java/me/shedaniel/architectury/hooks/biome/GenerationProperties.java @@ -24,23 +24,18 @@ import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; import net.minecraft.world.level.levelgen.surfacebuilders.ConfiguredSurfaceBuilder; -import org.jetbrains.annotations.NotNull; import java.util.List; import java.util.Optional; import java.util.function.Supplier; public interface GenerationProperties { - @NotNull Optional>> getSurfaceBuilder(); - @NotNull List>> getCarvers(GenerationStep.Carving carving); - @NotNull List>>> getFeatures(); - @NotNull List>> getStructureStarts(); interface Mutable extends GenerationProperties { diff --git a/common/src/main/java/me/shedaniel/architectury/hooks/biome/SpawnProperties.java b/common/src/main/java/me/shedaniel/architectury/hooks/biome/SpawnProperties.java index 228a9ad3..1a7a106a 100644 --- a/common/src/main/java/me/shedaniel/architectury/hooks/biome/SpawnProperties.java +++ b/common/src/main/java/me/shedaniel/architectury/hooks/biome/SpawnProperties.java @@ -22,7 +22,6 @@ package me.shedaniel.architectury.hooks.biome; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.level.biome.MobSpawnSettings; -import org.jetbrains.annotations.NotNull; import java.util.List; import java.util.Map; @@ -31,16 +30,13 @@ import java.util.function.BiPredicate; public interface SpawnProperties { float getCreatureProbability(); - @NotNull Map> getSpawners(); - @NotNull Map, MobSpawnSettings.MobSpawnCost> getMobSpawnCosts(); boolean isPlayerSpawnFriendly(); interface Mutable extends SpawnProperties { - @NotNull Mutable setCreatureProbability(float probability); Mutable addSpawn(MobCategory category, MobSpawnSettings.SpawnerData data); @@ -53,7 +49,6 @@ public interface SpawnProperties { Mutable clearSpawnCost(EntityType entityType); - @NotNull Mutable setPlayerSpawnFriendly(boolean friendly); } } diff --git a/common/src/main/java/me/shedaniel/architectury/platform/Mod.java b/common/src/main/java/me/shedaniel/architectury/platform/Mod.java index 45241b26..f3a332ed 100644 --- a/common/src/main/java/me/shedaniel/architectury/platform/Mod.java +++ b/common/src/main/java/me/shedaniel/architectury/platform/Mod.java @@ -22,7 +22,6 @@ package me.shedaniel.architectury.platform; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.gui.screens.Screen; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.nio.file.Path; @@ -30,16 +29,12 @@ import java.util.Collection; import java.util.Optional; public interface Mod { - @NotNull String getModId(); - @NotNull String getVersion(); - @NotNull String getName(); - @NotNull String getDescription(); /** @@ -48,25 +43,19 @@ public interface Mod { * @param preferredSize the preferred logo size, only used in fabric * @return the logo file path relative to the file */ - @NotNull Optional getLogoFile(int preferredSize); - @NotNull Path getFilePath(); - @NotNull Collection getAuthors(); @Nullable Collection getLicense(); - @NotNull Optional getHomepage(); - @NotNull Optional getSources(); - @NotNull Optional getIssueTracker(); @Environment(EnvType.CLIENT) diff --git a/common/src/main/java/me/shedaniel/architectury/platform/Platform.java b/common/src/main/java/me/shedaniel/architectury/platform/Platform.java index a6543cde..ed98685d 100644 --- a/common/src/main/java/me/shedaniel/architectury/platform/Platform.java +++ b/common/src/main/java/me/shedaniel/architectury/platform/Platform.java @@ -21,10 +21,11 @@ package me.shedaniel.architectury.platform; import me.shedaniel.architectury.Architectury; import me.shedaniel.architectury.annotations.ExpectPlatform; +import me.shedaniel.architectury.targets.ArchitecturyTarget; import me.shedaniel.architectury.utils.Env; import net.fabricmc.api.EnvType; import net.minecraft.SharedConstants; -import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.ApiStatus; import java.nio.file.Path; import java.util.Collection; @@ -37,8 +38,11 @@ public final class Platform { /** * @return the current mod loader, either "fabric" or "forge" + * @deprecated does not reflect the true mod loader, "quilt" is never returned, + * use {@link ArchitecturyTarget#getCurrentTarget()} instead. */ - @NotNull + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "2.0") public static String getModLoader() { return Architectury.getModLoader(); } @@ -68,30 +72,25 @@ public final class Platform { } } - @NotNull public static String getMinecraftVersion() { return SharedConstants.getCurrentVersion().getId(); } - @NotNull @ExpectPlatform public static Path getGameFolder() { throw new AssertionError(); } - @NotNull @ExpectPlatform public static Path getConfigFolder() { throw new AssertionError(); } - @NotNull @ExpectPlatform public static Env getEnvironment() { throw new AssertionError(); } - @NotNull @ExpectPlatform public static EnvType getEnv() { throw new AssertionError(); @@ -102,13 +101,11 @@ public final class Platform { throw new AssertionError(); } - @NotNull @ExpectPlatform public static Mod getMod(String id) { throw new AssertionError(); } - @NotNull public static Optional getOptionalMod(String id) { try { return Optional.of(getMod(id)); @@ -117,13 +114,11 @@ public final class Platform { } } - @NotNull @ExpectPlatform public static Collection getMods() { throw new AssertionError(); } - @NotNull @ExpectPlatform public static Collection getModIds() { throw new AssertionError(); diff --git a/common/src/main/java/me/shedaniel/architectury/registry/BiomeModifications.java b/common/src/main/java/me/shedaniel/architectury/registry/BiomeModifications.java index 96fc62c0..bd2e994f 100644 --- a/common/src/main/java/me/shedaniel/architectury/registry/BiomeModifications.java +++ b/common/src/main/java/me/shedaniel/architectury/registry/BiomeModifications.java @@ -23,7 +23,6 @@ import com.google.common.base.Predicates; import me.shedaniel.architectury.annotations.ExpectPlatform; import me.shedaniel.architectury.hooks.biome.BiomeProperties; import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.NotNull; import java.util.function.BiConsumer; import java.util.function.Predicate; @@ -66,10 +65,8 @@ public final class BiomeModifications { } public interface BiomeContext { - @NotNull ResourceLocation getKey(); - @NotNull BiomeProperties getProperties(); } } diff --git a/common/src/main/java/me/shedaniel/architectury/registry/BlockEntityRenderers.java b/common/src/main/java/me/shedaniel/architectury/registry/BlockEntityRenderers.java index 6a9eecbc..f7a1ba4e 100644 --- a/common/src/main/java/me/shedaniel/architectury/registry/BlockEntityRenderers.java +++ b/common/src/main/java/me/shedaniel/architectury/registry/BlockEntityRenderers.java @@ -34,7 +34,7 @@ import java.util.function.Function; public final class BlockEntityRenderers { private BlockEntityRenderers() {} - public static void registerRenderer(BlockEntityType type, Function> provider) { + public static void registerRenderer(BlockEntityType type, Function> provider) { registerRenderer(type, (BlockEntityRendererProvider.Context context) -> provider.apply(context.getBlockEntityRenderDispatcher())); } diff --git a/common/src/main/java/me/shedaniel/architectury/registry/DeferredRegister.java b/common/src/main/java/me/shedaniel/architectury/registry/DeferredRegister.java index 5b9514c9..fc03cca4 100644 --- a/common/src/main/java/me/shedaniel/architectury/registry/DeferredRegister.java +++ b/common/src/main/java/me/shedaniel/architectury/registry/DeferredRegister.java @@ -22,7 +22,6 @@ package me.shedaniel.architectury.registry; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.LazyLoadedValue; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -31,42 +30,36 @@ import java.util.Objects; import java.util.function.Supplier; public class DeferredRegister { - @NotNull private final Supplier registriesSupplier; - @NotNull private final ResourceKey> key; private final List> entries = new ArrayList<>(); private boolean registered = false; @Nullable private String modId; - private DeferredRegister(@NotNull Supplier registriesSupplier, @NotNull ResourceKey> key, @Nullable String modId) { + private DeferredRegister(Supplier registriesSupplier, ResourceKey> key, @Nullable String modId) { this.registriesSupplier = Objects.requireNonNull(registriesSupplier); this.key = Objects.requireNonNull(key); this.modId = modId; } - @NotNull - public static DeferredRegister create(@NotNull String modId, @NotNull ResourceKey> key) { + public static DeferredRegister create(String modId, ResourceKey> key) { LazyLoadedValue value = new LazyLoadedValue<>(() -> Registries.get(modId)); return new DeferredRegister<>(value::get, key, Objects.requireNonNull(modId)); } - @NotNull @Deprecated - public static DeferredRegister create(@NotNull Registries registries, @NotNull ResourceKey> key) { + public static DeferredRegister create(Registries registries, ResourceKey> key) { return new DeferredRegister<>(() -> registries, key, null); } - @NotNull @Deprecated - public static DeferredRegister create(@NotNull Supplier registries, @NotNull ResourceKey> key) { + public static DeferredRegister create(Supplier registries, ResourceKey> key) { return new DeferredRegister<>(registries, key, null); } - @NotNull @Deprecated - public static DeferredRegister create(@NotNull LazyLoadedValue registries, @NotNull ResourceKey> key) { + public static DeferredRegister create(LazyLoadedValue registries, ResourceKey> key) { return create(registries::get, key); } @@ -110,12 +103,12 @@ public class DeferredRegister { } @Override - public @NotNull ResourceLocation getRegistryId() { + public ResourceLocation getRegistryId() { return key.location(); } @Override - public @NotNull ResourceLocation getId() { + public ResourceLocation getId() { return id; } diff --git a/common/src/main/java/me/shedaniel/architectury/registry/Registries.java b/common/src/main/java/me/shedaniel/architectury/registry/Registries.java index 6023d189..7c573ae0 100644 --- a/common/src/main/java/me/shedaniel/architectury/registry/Registries.java +++ b/common/src/main/java/me/shedaniel/architectury/registry/Registries.java @@ -25,7 +25,6 @@ import me.shedaniel.architectury.registry.registries.RegistryBuilder; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Map; @@ -39,7 +38,6 @@ public final class Registries { private final RegistryProvider provider; private final String modId; - @NotNull public static Registries get(String modId) { return REGISTRIES.computeIfAbsent(modId, Registries::new); } @@ -49,18 +47,15 @@ public final class Registries { this.modId = modId; } - @NotNull public Registry get(ResourceKey> key) { return this.provider.get(key); } - @NotNull @Deprecated public Registry get(net.minecraft.core.Registry registry) { return this.provider.get(registry); } - @NotNull @SafeVarargs public final > RegistryBuilder builder(ResourceLocation registryId, T... typeGetter) { if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!"); @@ -103,7 +98,6 @@ public final class Registries { throw new AssertionError(); } - @NotNull public String getModId() { return modId; } diff --git a/common/src/main/java/me/shedaniel/architectury/registry/Registry.java b/common/src/main/java/me/shedaniel/architectury/registry/Registry.java index a25a5b3d..972c868e 100644 --- a/common/src/main/java/me/shedaniel/architectury/registry/Registry.java +++ b/common/src/main/java/me/shedaniel/architectury/registry/Registry.java @@ -21,7 +21,6 @@ package me.shedaniel.architectury.registry; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Map; @@ -30,21 +29,17 @@ import java.util.Set; import java.util.function.Supplier; public interface Registry extends Iterable { - @NotNull default Supplier delegate(ResourceLocation id) { return delegateSupplied(id); } - @NotNull RegistrySupplier delegateSupplied(ResourceLocation id); - @NotNull - default Supplier register(ResourceLocation id, Supplier supplier) { + default Supplier register(ResourceLocation id, Supplier supplier) { return registerSupplied(id, supplier); } - @NotNull - RegistrySupplier registerSupplied(ResourceLocation id, Supplier supplier); + RegistrySupplier registerSupplied(ResourceLocation id, Supplier supplier); @Nullable ResourceLocation getId(T obj); diff --git a/common/src/main/java/me/shedaniel/architectury/registry/RegistrySupplier.java b/common/src/main/java/me/shedaniel/architectury/registry/RegistrySupplier.java index cdeedf4e..4c8fd4eb 100644 --- a/common/src/main/java/me/shedaniel/architectury/registry/RegistrySupplier.java +++ b/common/src/main/java/me/shedaniel/architectury/registry/RegistrySupplier.java @@ -20,7 +20,6 @@ package me.shedaniel.architectury.registry; import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Optional; @@ -32,13 +31,11 @@ public interface RegistrySupplier extends Supplier { /** * @return the identifier of the registry */ - @NotNull ResourceLocation getRegistryId(); /** * @return the identifier of the entry */ - @NotNull ResourceLocation getId(); /** @@ -54,7 +51,6 @@ public interface RegistrySupplier extends Supplier { return null; } - @NotNull default Optional toOptional() { return Optional.ofNullable(getOrNull()); } @@ -73,7 +69,6 @@ public interface RegistrySupplier extends Supplier { } } - @NotNull default Stream stream() { if (!isPresent()) { return Stream.empty(); diff --git a/common/src/main/java/me/shedaniel/architectury/registry/entity/EntityAttributes.java b/common/src/main/java/me/shedaniel/architectury/registry/entity/EntityAttributes.java new file mode 100644 index 00000000..fe919dc9 --- /dev/null +++ b/common/src/main/java/me/shedaniel/architectury/registry/entity/EntityAttributes.java @@ -0,0 +1,43 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package me.shedaniel.architectury.registry.entity; + +import me.shedaniel.architectury.annotations.ExpectPlatform; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; + +import java.util.function.Supplier; + +public final class EntityAttributes { + private EntityAttributes() {} + + /** + * Registers default attributes to entities. + * + * @param type the type of entity + * @param attribute the attributes to register + * @see net.minecraft.world.entity.ai.attributes.DefaultAttributes + */ + @ExpectPlatform + public static void register(Supplier> type, Supplier attribute) { + throw new AssertionError(); + } +} diff --git a/common/src/main/java/me/shedaniel/architectury/registry/fuel/FuelRegistry.java b/common/src/main/java/me/shedaniel/architectury/registry/fuel/FuelRegistry.java new file mode 100644 index 00000000..b2b0a0dd --- /dev/null +++ b/common/src/main/java/me/shedaniel/architectury/registry/fuel/FuelRegistry.java @@ -0,0 +1,51 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package me.shedaniel.architectury.registry.fuel; + +import me.shedaniel.architectury.annotations.ExpectPlatform; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.ItemLike; + +public final class FuelRegistry { + private FuelRegistry() {} + + /** + * Registers a burn time for items. + * + * @param time the new burn time, use {@code 0} for non-fuel items, + * and {@code -1} to use vanilla logic + * @param items the array of items to register for + */ + @ExpectPlatform + public static void register(int time, ItemLike... items) { + throw new AssertionError(); + } + + /** + * Returns the burn time of an {@link ItemStack}. + * + * @param stack the stack + * @return the burn time of the stack, returns {@code 0} if not a fuel + */ + @ExpectPlatform + public static int get(ItemStack stack) { + throw new AssertionError(); + } +} diff --git a/common/src/main/java/me/shedaniel/architectury/registry/registries/RegistryBuilder.java b/common/src/main/java/me/shedaniel/architectury/registry/registries/RegistryBuilder.java index cb130c6a..a6e2258a 100644 --- a/common/src/main/java/me/shedaniel/architectury/registry/registries/RegistryBuilder.java +++ b/common/src/main/java/me/shedaniel/architectury/registry/registries/RegistryBuilder.java @@ -21,22 +21,17 @@ package me.shedaniel.architectury.registry.registries; import me.shedaniel.architectury.core.RegistryEntry; import me.shedaniel.architectury.registry.Registry; -import org.jetbrains.annotations.NotNull; public interface RegistryBuilder> { - @NotNull Registry build(); - @NotNull - RegistryBuilder option(@NotNull RegistryOption option); + RegistryBuilder option(RegistryOption option); - @NotNull default RegistryBuilder saveToDisc() { return option(StandardRegistryOption.SAVE_TO_DISC); } - @NotNull default RegistryBuilder syncToClients() { return option(StandardRegistryOption.SYNC_TO_CLIENTS); } -} \ No newline at end of file +} diff --git a/fabric/src/main/java/me/shedaniel/architectury/platform/fabric/PlatformImpl.java b/fabric/src/main/java/me/shedaniel/architectury/platform/fabric/PlatformImpl.java index 91d2c1cd..4d173c7c 100644 --- a/fabric/src/main/java/me/shedaniel/architectury/platform/fabric/PlatformImpl.java +++ b/fabric/src/main/java/me/shedaniel/architectury/platform/fabric/PlatformImpl.java @@ -31,14 +31,14 @@ import org.jetbrains.annotations.Nullable; import java.nio.file.Path; import java.util.Collection; -import java.util.HashMap; import java.util.Map; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; public class PlatformImpl { - public static final Map CONFIG_SCREENS = new HashMap<>(); - private static final Map mods = new HashMap<>(); + public static final Map CONFIG_SCREENS = new ConcurrentHashMap<>(); + private static final Map mods = new ConcurrentHashMap<>(); public static Path getGameFolder() { return FabricLoader.getInstance().getGameDir(); diff --git a/fabric/src/main/java/me/shedaniel/architectury/registry/entity/fabric/EntityAttributesImpl.java b/fabric/src/main/java/me/shedaniel/architectury/registry/entity/fabric/EntityAttributesImpl.java new file mode 100644 index 00000000..5d881ecf --- /dev/null +++ b/fabric/src/main/java/me/shedaniel/architectury/registry/entity/fabric/EntityAttributesImpl.java @@ -0,0 +1,33 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package me.shedaniel.architectury.registry.entity.fabric; + +import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; + +import java.util.function.Supplier; + +public class EntityAttributesImpl { + public static void register(Supplier> type, Supplier attribute) { + FabricDefaultAttributeRegistry.register(type.get(), attribute.get()); + } +} diff --git a/fabric/src/main/java/me/shedaniel/architectury/registry/fabric/BlockEntityRenderersImpl.java b/fabric/src/main/java/me/shedaniel/architectury/registry/fabric/BlockEntityRenderersImpl.java index 14f1263d..42d83985 100644 --- a/fabric/src/main/java/me/shedaniel/architectury/registry/fabric/BlockEntityRenderersImpl.java +++ b/fabric/src/main/java/me/shedaniel/architectury/registry/fabric/BlockEntityRenderersImpl.java @@ -25,7 +25,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; public class BlockEntityRenderersImpl { - public static void registerRenderer(BlockEntityType type, BlockEntityRendererProvider provider) { + public static void registerRenderer(BlockEntityType type, BlockEntityRendererProvider provider) { BlockEntityRendererRegistry.INSTANCE.register(type, provider); } } diff --git a/fabric/src/main/java/me/shedaniel/architectury/registry/fabric/RegistriesImpl.java b/fabric/src/main/java/me/shedaniel/architectury/registry/fabric/RegistriesImpl.java index 65139465..89430e0e 100644 --- a/fabric/src/main/java/me/shedaniel/architectury/registry/fabric/RegistriesImpl.java +++ b/fabric/src/main/java/me/shedaniel/architectury/registry/fabric/RegistriesImpl.java @@ -155,9 +155,9 @@ public class RegistriesImpl { } @Override - public @NotNull RegistrySupplier registerSupplied(ResourceLocation id, Supplier supplier) { + public @NotNull RegistrySupplier registerSupplied(ResourceLocation id, Supplier supplier) { net.minecraft.core.Registry.register(delegate, id, supplier.get()); - return delegateSupplied(id); + return (RegistrySupplier) delegateSupplied(id); } @Override diff --git a/fabric/src/main/java/me/shedaniel/architectury/registry/fuel/fabric/FuelRegistryImpl.java b/fabric/src/main/java/me/shedaniel/architectury/registry/fuel/fabric/FuelRegistryImpl.java new file mode 100644 index 00000000..e0981f55 --- /dev/null +++ b/fabric/src/main/java/me/shedaniel/architectury/registry/fuel/fabric/FuelRegistryImpl.java @@ -0,0 +1,41 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package me.shedaniel.architectury.registry.fuel.fabric; + +import net.fabricmc.fabric.api.registry.FuelRegistry; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.ItemLike; + +public class FuelRegistryImpl { + public static void register(int time, ItemLike... items) { + for (ItemLike item : items) { + if (time >= 0) { + FuelRegistry.INSTANCE.add(item, time); + } else { + FuelRegistry.INSTANCE.remove(item); + } + } + } + + public static int get(ItemStack stack) { + Integer time = FuelRegistry.INSTANCE.get(stack.getItem()); + return time == null ? 0 : time; + } +} diff --git a/forge/src/main/java/me/shedaniel/architectury/platform/forge/PlatformImpl.java b/forge/src/main/java/me/shedaniel/architectury/platform/forge/PlatformImpl.java index fb9883b2..29c8fb66 100644 --- a/forge/src/main/java/me/shedaniel/architectury/platform/forge/PlatformImpl.java +++ b/forge/src/main/java/me/shedaniel/architectury/platform/forge/PlatformImpl.java @@ -37,10 +37,11 @@ import javax.annotation.Nonnull; import java.net.URL; import java.nio.file.Path; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; public class PlatformImpl { - private static final Map mods = new HashMap<>(); + private static final Map mods = new ConcurrentHashMap<>(); public static Path getGameFolder() { return FMLPaths.GAMEDIR.get(); @@ -165,4 +166,4 @@ public class PlatformImpl { container.registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (minecraft, screen) -> configurationScreenProvider.provide(screen)); } } -} \ No newline at end of file +} diff --git a/forge/src/main/java/me/shedaniel/architectury/registry/entity/forge/EntityAttributesImpl.java b/forge/src/main/java/me/shedaniel/architectury/registry/entity/forge/EntityAttributesImpl.java new file mode 100644 index 00000000..369127aa --- /dev/null +++ b/forge/src/main/java/me/shedaniel/architectury/registry/entity/forge/EntityAttributesImpl.java @@ -0,0 +1,54 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package me.shedaniel.architectury.registry.entity.forge; + +import me.shedaniel.architectury.forge.ArchitecturyForge; +import me.shedaniel.architectury.platform.forge.EventBuses; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; +import net.minecraftforge.event.entity.EntityAttributeCreationEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Supplier; + +public class EntityAttributesImpl { + private static final Map>, Supplier> ATTRIBUTES = new ConcurrentHashMap<>(); + + public static void register(Supplier> type, Supplier attribute) { + ATTRIBUTES.put(type, attribute); + } + + static { + EventBuses.onRegistered(ArchitecturyForge.MOD_ID, bus -> { + bus.register(EntityAttributesImpl.class); + }); + } + + @SubscribeEvent + public static void event(EntityAttributeCreationEvent event) { + for (Map.Entry>, Supplier> entry : ATTRIBUTES.entrySet()) { + event.put(entry.getKey().get(), entry.getValue().get().build()); + } + } +} diff --git a/forge/src/main/java/me/shedaniel/architectury/registry/forge/BlockEntityRenderersImpl.java b/forge/src/main/java/me/shedaniel/architectury/registry/forge/BlockEntityRenderersImpl.java index 109b784c..3bdd56b0 100644 --- a/forge/src/main/java/me/shedaniel/architectury/registry/forge/BlockEntityRenderersImpl.java +++ b/forge/src/main/java/me/shedaniel/architectury/registry/forge/BlockEntityRenderersImpl.java @@ -28,7 +28,7 @@ import net.minecraftforge.fml.client.registry.ClientRegistry; import java.util.function.Function; public class BlockEntityRenderersImpl { - public static void registerRenderer(BlockEntityType type, Function> provider) { + public static void registerRenderer(BlockEntityType type, Function> provider) { ClientRegistry.bindTileEntityRenderer(type, provider); } } diff --git a/forge/src/main/java/me/shedaniel/architectury/registry/forge/RegistriesImpl.java b/forge/src/main/java/me/shedaniel/architectury/registry/forge/RegistriesImpl.java index a1c13104..e7414174 100644 --- a/forge/src/main/java/me/shedaniel/architectury/registry/forge/RegistriesImpl.java +++ b/forge/src/main/java/me/shedaniel/architectury/registry/forge/RegistriesImpl.java @@ -200,9 +200,9 @@ public class RegistriesImpl { } @Override - public @NotNull RegistrySupplier registerSupplied(ResourceLocation id, Supplier supplier) { + public @NotNull RegistrySupplier registerSupplied(ResourceLocation id, Supplier supplier) { net.minecraft.core.Registry.register(delegate, id, supplier.get()); - return delegateSupplied(id); + return (RegistrySupplier) delegateSupplied(id); } @Override @@ -317,10 +317,10 @@ public class RegistriesImpl { } @Override - public @NotNull RegistrySupplier registerSupplied(ResourceLocation id, Supplier supplier) { + public @NotNull RegistrySupplier registerSupplied(ResourceLocation id, Supplier supplier) { RegistryObject registryObject = RegistryObject.of(id, delegate); registry.put(delegate.getRegistrySuperType(), registryObject, () -> supplier.get().setRegistryName(id)); - return new RegistrySupplier() { + return new RegistrySupplier() { @Override public @NotNull ResourceLocation getRegistryId() { return delegate.getRegistryName(); @@ -337,8 +337,8 @@ public class RegistriesImpl { } @Override - public T get() { - return (T) registryObject.get(); + public E get() { + return (E) registryObject.get(); } @Override diff --git a/forge/src/main/java/me/shedaniel/architectury/registry/fuel/forge/FuelRegistryImpl.java b/forge/src/main/java/me/shedaniel/architectury/registry/fuel/forge/FuelRegistryImpl.java new file mode 100644 index 00000000..aae8ee5b --- /dev/null +++ b/forge/src/main/java/me/shedaniel/architectury/registry/fuel/forge/FuelRegistryImpl.java @@ -0,0 +1,56 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package me.shedaniel.architectury.registry.fuel.forge; + +import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.ItemLike; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; + +public class FuelRegistryImpl { + private static final Object2IntMap ITEMS = new Object2IntLinkedOpenHashMap<>(); + + static { + MinecraftForge.EVENT_BUS.register(FuelRegistryImpl.class); + } + + public static void register(int time, ItemLike... items) { + for (ItemLike item : items) { + ITEMS.put(item, time); + } + } + + public static int get(ItemStack stack) { + return ForgeHooks.getBurnTime(stack); + } + + @SubscribeEvent + public static void event(FurnaceFuelBurnTimeEvent event) { + if (event.getItemStack().isEmpty()) return; + int time = ITEMS.getOrDefault(event.getItemStack().getItem(), Integer.MIN_VALUE); + if (time != Integer.MIN_VALUE) { + event.setBurnTime(time); + } + } +} diff --git a/gradle.properties b/gradle.properties index b21100cb..66d30fe7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -minecraft_version=21w17a -supported_version=21w17a +minecraft_version=21w19a +supported_version=21w19a cf_type=beta diff --git a/settings.gradle b/settings.gradle index 6395da1e..c67a5630 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,7 @@ pluginManagement { repositories { maven { url "https://maven.fabricmc.net/" } - maven { url "https://maven.shedaniel.me/" } + maven { url "https://maven.architectury.dev/" } maven { url "https://files.minecraftforge.net/maven/" } gradlePluginPortal() }