Skip to content
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
1 change: 1 addition & 0 deletions Version Notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CCA Switched from onyxstudios to ladysnake on version 6.0.0, or mc 1.20.5+6.
13 changes: 13 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ repositories {
strictMaven("https://maven.ladysnake.org/releases", "Ladysnake")
strictMaven("https://maven.fzzyhmstrs.me/", "FZZY Maven")
strictMaven("https://maven.terraformersmc.com/", "Terraformers")
strictMaven("https://maven.nucleoid.xyz/", "Nucleoid")
}

subprojects {
tasks.withType<Test>().configureEach {
enabled = false
}
}

project(":1.21.4") {
tasks.withType<Test>().configureEach {
enabled = true
}
}

dependencies {
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ mod.id=composer_reloaded
mod.archives_base_name=composer-reloaded
mod.name=Composer Reloaded

deps.fabric_loader=0.17.3

publish.modrinth=WJ1ahCDP

junit_version=6.0.1
Expand Down
5 changes: 2 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ plugins {

stonecutter {
create(rootProject) {
// See https://stonecutter.kikugie.dev/wiki/start/#choosing-minecraft-versions
versions("1.20.1", "1.21.4")
vcsVersion = "1.20.1"
versions("1.20.1", "1.20.4", "1.20.6", "1.21", "1.21.3", "1.21.4")
vcsVersion = "1.21.4"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@

import java.util.Optional;

//? minecraft: >=1.21.4 {
//? minecraft: >=1.20.6 {
import org.lilbrocodes.composer_reloaded.api.v1.datafix.impl.SimpleItemFixer;
import static org.lilbrocodes.composer_reloaded.internal.ComposerReloaded.LOGGER;
//? }

public class DataFixerRegistry {
public static final AbstractPseudoRegistry<Item> ITEM = new AbstractPseudoRegistry.Impl<>() {
@Override
@SuppressWarnings("unchecked")
public Item register(Identifier id, Item value) {
//? if minecraft: >=1.21.4
//? if minecraft: >=1.20.6
if (value instanceof SimpleItemFixer simple && simple.copyNbt()) LOGGER.warn("Copying raw NBT in a simple data fixer does not work on 1.21.4. Consider using a custom data fixer to copy components manually, or disable copyNbt!");
return super.register(id, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.lilbrocodes.composer_reloaded.api.v1.registry.lazy.feature.Feature;
import org.lilbrocodes.composer_reloaded.api.v1.util.misc.Translatable;

//? if minecraft: <=1.20.1 {
//? if minecraft: <=1.20.4 {
/*import org.lilbrocodes.composer_reloaded.api.v1.util.misc.TranslatableSoundEvent;
*///? } else {
import net.minecraft.registry.RegistryWrapper;
Expand All @@ -32,7 +32,7 @@
public abstract class ComposerLanguageProvider extends FabricLanguageProvider {
protected TranslationBuilder builder;

//? if minecraft: <=1.20.1 {
//? if minecraft: <=1.20.4 {
/*protected ComposerLanguageProvider(FabricDataOutput dataOutput) {
super(dataOutput);
}
Expand All @@ -42,14 +42,14 @@ protected ComposerLanguageProvider(FabricDataOutput dataOutput, CompletableFutur
}
//?}

//? if minecraft: <=1.20.1
//? if minecraft: <=1.20.4
//@Override
public void generateTranslations(TranslationBuilder translationBuilder) {
this.builder = translationBuilder;
generate();
}

//? if minecraft: >=1.21.4 {
//? if minecraft: >=1.20.6 {
@Override
public void generateTranslations(RegistryWrapper.WrapperLookup wrapperLookup, TranslationBuilder translationBuilder) {
generateTranslations(translationBuilder);
Expand All @@ -67,7 +67,7 @@ public String suffix() {
// Custom

public void feature(FeatureHandle feature, String translation) {
if (feature.id() != null) add(feature.getTranslationKey("feature.description"), translation);
if (feature.id() != null) add(feature.getTranslationKey(), translation);
}

public void feature(Feature feature, String translation) {
Expand All @@ -94,14 +94,14 @@ public <T extends Enum<T> & EnumTranslatable> void enumTranslatable(Class<T> enu
for (int i = 0; i < constants.length; i++) add("%s.%s".formatted(prefix, constants[i].name()), values[i]);
}

//? if minecraft: <=1.20.1 {
//? if minecraft: <=1.20.4 {
/*public void sound(TranslatableSoundEvent sound, String value) {
add(sound, value);
}
*///?}

public void sound(SoundEvent sound, String value) {
add(sound./*? if minecraft: >=1.21.4 { */id/*?} else {*//*getId*//*? }*/(), value);
add(sound./*? if minecraft: >=1.21.3 { */id/*?} else {*//*getId*//*? }*/(), value);
}

public void add(Translatable translatable, String value) {
Expand Down Expand Up @@ -150,14 +150,22 @@ public void entity(EntityType<?> entityType, String value) {
builder.add(entityType, value);
}

//? if minecraft: <=1.20.1 {
//? if minecraft: <=1.20.4 {
/*public void enchantment(Enchantment enchantment, String value) {
builder.add(enchantment, value);
}

public void attribute(EntityAttribute entityAttribute, String value) {
builder.add(entityAttribute, value);
}
*///?} else if minecraft: <=1.20.6 {
/*public void enchantment(Enchantment enchantment, String value) {
builder.add(enchantment, value);
}

public void attribute(RegistryEntry<EntityAttribute> entityAttribute, String value) {
builder.add(entityAttribute, value);
}
*///?} else {
public void enchantment(RegistryKey<Enchantment> enchantment, String value) {
builder.addEnchantment(enchantment, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.function.Function;
import java.util.function.Supplier;

//? if minecraft: <=1.20.1 {
//? if minecraft: <=1.21.3 {
/*import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.minecraft.data.client.BlockStateModelGenerator;
import net.minecraft.data.client.BlockStateSupplier;
Expand All @@ -24,7 +24,7 @@
import net.minecraft.util.Identifier;
import java.util.HashSet;
import java.util.Set;
*///? } else if minecraft: >=1.21.4 {
*///? } else {
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
Expand All @@ -42,7 +42,7 @@
import net.minecraft.client.data.*;
//? }

//? if minecraft: <=1.20.1 {
//? if minecraft: <=1.21.3 {
/*public abstract class ComposerModelProvider implements DataProvider {
private final DataOutput.PathResolver blockstatesPathResolver;
private final DataOutput.PathResolver modelsPathResolver;
Expand Down Expand Up @@ -150,7 +150,7 @@ public static class ModelSuppliers implements BiConsumer<Identifier, ModelSuppli
public void accept(Identifier identifier, ModelSupplier modelSupplier) {
Supplier<JsonElement> supplier = this.modelSuppliers.put(identifier, modelSupplier);
if (supplier != null) {
throw new IllegalStateException("Duplicate model definition for " + String.valueOf(identifier));
throw new IllegalStateException("Duplicate model definition for " + identifier);
}
}

Expand All @@ -171,7 +171,7 @@ public void accept(BlockStateSupplier blockStateSupplier) {
Block block = blockStateSupplier.getBlock();
BlockStateSupplier blockStateSupplier2 = this.blockStateSuppliers.put(block, blockStateSupplier);
if (blockStateSupplier2 != null) {
throw new IllegalStateException("Duplicate blockstate definition for " + String.valueOf(block));
throw new IllegalStateException("Duplicate blockstate definition for " + block);
}
}

Expand Down Expand Up @@ -201,9 +201,9 @@ public void accept(Item item, ItemModel.Unbaked model) {
}

private void accept(Item item, ItemAsset asset) {
ItemAsset itemAsset = (ItemAsset)this.itemAssets.put(item, asset);
ItemAsset itemAsset = this.itemAssets.put(item, asset);
if (itemAsset != null) {
throw new IllegalStateException("Duplicate item model definition for " + String.valueOf(item));
throw new IllegalStateException("Duplicate item model definition for " + item);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static <T> T get(NbtCompound tag, Class<T> clazz) {
* @return an instance of the requested data type, or null no data is present
*/
public static <T> T get(ItemStack stack, Class<T> clazz) {
//? if minecraft: <=1.20.1 {
//? if minecraft: <=1.20.4 {
/*return get(stack.getOrCreateNbt(), clazz);
*///? } else {
return null; // TODO: Implement this to work with the new system
Expand All @@ -74,7 +74,7 @@ public static <T> T get(ItemStack stack, Class<T> clazz) {
* @param <T> the type of the data
*/
public static <T extends NbtSerializable<T>> void save(ItemStack stack, T data) {
//? if minecraft: <=1.20.1 {
//? if minecraft: <=1.20.4 {
/*NbtCompound root = stack.getOrCreateNbt();
save(root, data);
stack.setNbt(root);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Builder sound(Identifier id) {
}

public Builder sound(SoundEvent sound) {
return this.sound(sound./*? if minecraft: <=1.20.1 { *//*getId*//*? } else {*/id/*?}*/());
return this.sound(sound./*? if minecraft: <=1.21 { *//*getId*//*? } else {*/id/*?}*/());
}

public Builder sound(RegistryEntry.Reference<SoundEvent> sound) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

//? if minecraft: >=1.21.4
//? if minecraft: >=1.20.6
import static org.lilbrocodes.composer_reloaded.internal.registry.ModDataComponentTypes.STEPS;

/**
Expand All @@ -19,7 +19,7 @@
*/
@SuppressWarnings("EmptyMethod")
public abstract class AbstractProgressItem extends Item {
//? if minecraft: <=1.20.1
//? if minecraft: <=1.20.4
//private static final String STEP_KEY = "Step";
private final int maxSteps;

Expand Down Expand Up @@ -56,10 +56,10 @@ protected void onFinishProcess(ItemStack stack, World world, PlayerEntity player
}

/** Returns the current step stored in the item's NBT. */
//? if minecraft: >=1.21.4
//? if minecraft: >=1.20.6
@SuppressWarnings("DataFlowIssue")
public static int getStep(ItemStack stack) {
//? if minecraft: <=1.20.1 {
//? if minecraft: <=1.20.4 {
/*return stack.getOrCreateNbt().getInt(STEP_KEY);
*///? } else {
return stack.contains(STEPS) ? stack.get(STEPS) : 0;
Expand All @@ -68,7 +68,7 @@ public static int getStep(ItemStack stack) {

/** Sets the current step in the item's NBT. */
public static void setStep(ItemStack stack, int value) {
//? if minecraft: <=1.20.1 {
//? if minecraft: <=1.20.4 {
/*stack.getOrCreateNbt().putInt(STEP_KEY, value);
*///? } else {
stack.set(STEPS, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import net.minecraft.item.Item;

//? if minecraft: >=1.21.4
//? if minecraft: >=1.20.6
import org.lilbrocodes.composer_reloaded.internal.registry.ModDataComponentTypes;

public class ComposerItemSettings extends Item.Settings {
//? if minecraft: <=1.20.1 {
//? if minecraft: <=1.20.4 {
/*public boolean soulbound = false;
public boolean soulboundCanDrop = false;
*///? }

public ComposerItemSettings soulbound(boolean canDrop) {
//? if minecraft: >=1.21.4 {
//? if minecraft: >=1.20.6 {
component(ModDataComponentTypes.SOULBOUND, true);
component(ModDataComponentTypes.SOULBOUND_CAN_DROP, canDrop);
//? } else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.minecraft.item.ItemStack;
import java.util.Objects;

//? if minecraft: >=1.21.4 {
//? if minecraft: >=1.20.6 {
import org.lilbrocodes.composer_reloaded.internal.registry.ModDataComponentTypes;
//? } else {
/*import org.lilbrocodes.composer_reloaded.mixin.accessor.ItemMethodAccessor;
Expand All @@ -13,7 +13,7 @@ public class SoulboundComponent {
public static boolean isSoulbound(ItemStack stack) {
if (stack == null || stack.isEmpty()) return false;

//? if minecraft: >=1.21.4 {
//? if minecraft: >=1.20.6 {
return stack.contains(ModDataComponentTypes.SOULBOUND) && Objects.requireNonNull(stack.get(ModDataComponentTypes.SOULBOUND));
//?} else {
/*ItemMethodAccessor settings = ItemMethodAccessor.get(stack);
Expand All @@ -24,7 +24,7 @@ public static boolean isSoulbound(ItemStack stack) {
public static boolean canDropSoulbound(ItemStack stack) {
if (stack == null || stack.isEmpty()) return false;

//? if minecraft: >=1.21.4 {
//? if minecraft: >=1.20.6 {
return stack.contains(ModDataComponentTypes.SOULBOUND_CAN_DROP) ? Objects.requireNonNull(stack.get(ModDataComponentTypes.SOULBOUND_CAN_DROP)) : true;
//?} else {
/*ItemMethodAccessor settings = ItemMethodAccessor.get(stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.util.Identifier;
import java.util.function.UnaryOperator;

//? if minecraft: >=1.21.4 {
//? if minecraft: >=1.21.3 {
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;

Expand All @@ -23,7 +23,7 @@ public <T extends Block> T register(String name, T block) {
}

public <T extends Block> T register(String name, BlockProvider<T> newBlock, AbstractBlock.Settings settings) {
//? minecraft: >=1.21.4 {
//? minecraft: >=1.21.3 {
return register(name, newBlock.provide(settings.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(modId, name)))));
//? } else {
/*return register(name, newBlock.provide(settings));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package org.lilbrocodes.composer_reloaded.api.v1.registry.lazy;

//? if minecraft: >=1.21.4 {
//? if minecraft: >= 1.21 {
import net.minecraft.component.ComponentType;
//? } else if minecraft: >=1.20.6 {
/*import net.minecraft.component.DataComponentType;
*///? }

//? if minecraft: >=1.20.6 {
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
Expand All @@ -13,12 +18,12 @@ public DeferredDataComponentTypeRegistry(String modId) {
super(modId);
}

public <T> ComponentType<T> register(String name, UnaryOperator<ComponentType.Builder<T>> handler) {
public <T> /*? minecraft: >=1.21 {*/ComponentType/*? } else {*//*DataComponentType*//*? }*/<T> register(String name, UnaryOperator</*? minecraft: >=1.21 {*/ComponentType/*? } else {*//*DataComponentType*//*? }*/.Builder<T>> handler) {
return Registry.register(
Registries.DATA_COMPONENT_TYPE,
Identifier.of(modId, name),
handler.apply(ComponentType.builder()).build()
handler.apply(/*? minecraft: >=1.21 {*/ComponentType/*? } else {*//*DataComponentType*//*? }*/.builder()).build()
);
}
}
//? }
//? }
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

//? minecraft: >=1.21.4 {
//? minecraft: >=1.21.3 {
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
//? }
Expand All @@ -22,7 +22,8 @@ public <T extends Entity> EntityType<T> register(String name, EntityType<T> type
return Registry.register(Registries.ENTITY_TYPE, id, type);
}

@SuppressWarnings("deprecation")
public <T extends Entity> EntityType<T> register(String name, FabricEntityTypeBuilder<T> builder) {
return register(name, builder.build(/*? if minecraft: >=1.21.4 { */RegistryKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of(modId, name))/*?}*/));
return register(name, builder.build(/*? if minecraft: >=1.21.3 { */RegistryKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of(modId, name))/*?}*/));
}
}
Loading
Loading