Skip to content

Commit

Permalink
Definitely becoming a library mod now
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai committed Apr 29, 2024
1 parent b8e75a3 commit 36ab8ee
Show file tree
Hide file tree
Showing 24 changed files with 821 additions and 30 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ repositories {
// for more information about repositories.

maven {
url "https://maven.enjarai.nl/releases"
url "https://maven.enjarai.dev/releases"
}
maven {
url "https://maven.enjarai.nl/mirrors"
url "https://maven.enjarai.dev/mirrors"
}
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${stonecutter.current().version()}"
minecraft "com.mojang:minecraft:${stonecutter.current.version}"
mappings "net.fabricmc:yarn:${property('deps.yarn')}:v2"
modImplementation "net.fabricmc:fabric-loader:${property('deps.fabric_loader')}"

Expand Down Expand Up @@ -92,7 +92,7 @@ publishing {
repositories {
maven {
name = "enjaraiMaven"
url = "https://maven.enjarai.nl/releases"
url = "https://maven.enjarai.dev/releases"
credentials(PasswordCredentials)
authentication {
basic(BasicAuthentication)
Expand Down Expand Up @@ -127,7 +127,7 @@ assemble {
dependsOn(collectJars)
}

if (stonecutter.current().isActiveVersion()) {
if (stonecutter.current.isActive()) {
loom.runConfigs.testmodClient.ideConfigGenerated = true
loom.runConfigs.client.ideConfigGenerated = true

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

# Mod Information
mod.version=0.6.2
mod.version=0.7.0
mod.name=cicada-lib
mod.maven_group = nl.enjarai
mod.target=[VERSIONED]
Expand Down
8 changes: 6 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ pluginManagement {
}
mavenCentral()
gradlePluginPortal()

maven {
url = "https://maven.kikugie.dev/releases"
}
}
}

plugins {
id 'io.shcm.shsupercm.fabric.stonecutter' version '1.5'
id 'dev.kikugie.stonecutter' version "0.3.2"
}

stonecutter {
shared {
versions '1.20.2', '1.20.1'
versions '1.20.2', '1.20.1', '1.19.4'
vcsVersion '1.20.2'
}

Expand Down
222 changes: 222 additions & 0 deletions src/main/java/nl/enjarai/cicada/api/cursed/CursedRegistry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
package nl.enjarai.cicada.api.cursed;

import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.Lifecycle;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.entry.RegistryEntryList;
import net.minecraft.registry.entry.RegistryEntryOwner;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.random.Random;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.stream.Stream;

@SuppressWarnings("deprecation")
public record CursedRegistry<T>(RegistryKey<? extends Registry<T>> registryKey, Identifier defaultId, T defaultValue) implements Registry<T>, RegistryEntryOwner<T> {

@Override
public RegistryKey<? extends Registry<T>> getKey() {
return registryKey;
}

@Nullable
@Override
public Identifier getId(T value) {
return defaultId;
}

@Override
public Optional<RegistryKey<T>> getKey(T entry) {
return Optional.empty();
}

@Override
public int getRawId(@Nullable T value) {
return 0;
}

@Nullable
@Override
public T get(int index) {
return defaultValue;
}

@Override
public int size() {
return 1;
}

@Nullable
@Override
public T get(@Nullable RegistryKey<T> key) {
return defaultValue;
}

@Nullable
@Override
public T get(@Nullable Identifier id) {
return defaultValue;
}

@Override
public Lifecycle getEntryLifecycle(T entry) {
return Lifecycle.experimental();
}

@Override
public Lifecycle getLifecycle() {
return Lifecycle.experimental();
}

@Override
public Set<Identifier> getIds() {
return Set.of(defaultId);
}

@Override
public Set<Map.Entry<RegistryKey<T>, T>> getEntrySet() {
return Set.of();
}

@Override
public Set<RegistryKey<T>> getKeys() {
return Set.of();
}

@Override
public Optional<RegistryEntry.Reference<T>> getRandom(Random random) {
return Optional.empty();
}

@Override
public boolean containsId(Identifier id) {
return true;
}

@Override
public boolean contains(RegistryKey<T> key) {
return true;
}

@Override
public Registry<T> freeze() {
return this;
}

@Override
public RegistryEntry.Reference<T> createEntry(T value) {
return RegistryEntry.Reference.intrusive(this, value);
}

@Override
public Optional<RegistryEntry.Reference<T>> getEntry(int rawId) {
return Optional.empty();
}

@Override
public Optional<RegistryEntry.Reference<T>> getEntry(RegistryKey<T> key) {
return Optional.of(RegistryEntry.Reference.standAlone(this, key));
}

@Override
public RegistryEntry<T> getEntry(T value) {
return RegistryEntry.of(value);
}

@Override
public Stream<RegistryEntry.Reference<T>> streamEntries() {
return null;
}

@Override
public Optional<RegistryEntryList.Named<T>> getEntryList(TagKey<T> tag) {
return Optional.empty();
}

@Override
public RegistryEntryList.Named<T> getOrCreateEntryList(TagKey<T> tag) {
return RegistryEntryList.of(this, tag);
}

@Override
public Stream<Pair<TagKey<T>, RegistryEntryList.Named<T>>> streamTagsAndEntries() {
return Stream.empty();
}

@Override
public Stream<TagKey<T>> streamTags() {
return Stream.empty();
}

@Override
public void clearTags() {

}

@Override
public void populateTags(Map<TagKey<T>, List<RegistryEntry<T>>> tagEntries) {

}

@Override
public RegistryEntryOwner<T> getEntryOwner() {
return this;
}

@Override
public RegistryWrapper.Impl<T> getReadOnlyWrapper() {
return new RegistryWrapper.Impl<T>() {
@Override
public RegistryKey<? extends Registry<? extends T>> getRegistryKey() {
return CursedRegistry.this.registryKey;
}

@Override
public Lifecycle getLifecycle() {
return Lifecycle.experimental();
}

@Override
public Stream<RegistryEntry.Reference<T>> streamEntries() {
return Stream.empty();
}

@Override
public Stream<RegistryEntryList.Named<T>> streamTags() {
return Stream.empty();
}

@Override
public Optional<RegistryEntry.Reference<T>> getOptional(RegistryKey<T> key) {
return Optional.empty();
}

@Override
public Optional<RegistryEntryList.Named<T>> getOptional(TagKey<T> tag) {
return Optional.empty();
}
};
}

@NotNull
@Override
public Iterator<T> iterator() {
return new Iterator<T>() {
@Override
public boolean hasNext() {
return false;
}

@Override
public T next() {
return null;
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package nl.enjarai.cicada.api.cursed;

import com.mojang.datafixers.util.Either;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.entry.RegistryEntryOwner;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import nl.enjarai.cicada.Cicada;

import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;

public record CursedRegistryEntry<T>(T value, RegistryKey<? extends Registry<T>> key) implements RegistryEntry<T> {
@Override
public boolean hasKeyAndValue() {
return true;
}

@Override
public boolean matchesId(Identifier id) {
return false;
}

@Override
public boolean matchesKey(RegistryKey<T> key) {
return false;
}

@Override
public boolean isIn(TagKey<T> tag) {
return false;
}

@Override
public boolean matches(Predicate<RegistryKey<T>> predicate) {
return false;
}

@Override
public Either<RegistryKey<T>, T> getKeyOrValue() {
return Either.right(this.value);
}

@Override
public Optional<RegistryKey<T>> getKey() {
return Optional.of(RegistryKey.of(key, Cicada.id("dummy")));
}

@Override
public Type getType() {
return Type.DIRECT;
}

@Override
public String toString() {
return "CursedRegistryEntry(This is from CICADA, please report there for any issues caused){" + this.value + "}";
}

@Override
public boolean ownerEquals(RegistryEntryOwner<T> owner) {
return true;
}

@Override
public Stream<TagKey<T>> streamTags() {
return Stream.of();
}
}
Loading

0 comments on commit 36ab8ee

Please sign in to comment.