diff --git a/build.gradle b/build.gradle index cb4ba2e..f807b77 100644 --- a/build.gradle +++ b/build.gradle @@ -10,8 +10,16 @@ archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group +repositories { + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html + // for more information about repositories. +} + dependencies { - //to change the versions see the gradle.properties file + // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" @@ -26,35 +34,32 @@ dependencies { processResources { inputs.property "version", project.version - from(sourceSets.main.resources.srcDirs) { - include "fabric.mod.json" + filesMatching("fabric.mod.json") { expand "version": project.version } - - from(sourceSets.main.resources.srcDirs) { - exclude "fabric.mod.json" - } } -// ensure that the encoding is set to UTF-8, no matter what the system default is -// this fixes some edge cases with special characters not displaying correctly -// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" +tasks.withType(JavaCompile).configureEach { + // ensure that the encoding is set to UTF-8, no matter what the system default is + // this fixes some edge cases with special characters not displaying correctly + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html + // If Javadoc is generated, this must be specified in that task too. + it.options.encoding = "UTF-8" + + // Minecraft 1.17 (21w19a) upwards uses Java 16. it.options.release = 16 } -// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task -// if it is present. -// If you remove this task, sources will not be generated. -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() } jar { from("LICENSE") { - rename { "${it}_${project.archivesBaseName}" } + rename { "${it}_${project.archivesBaseName}"} } } @@ -72,9 +77,11 @@ publishing { } } - // select the repositories you want to publish to + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - // uncomment to publish to the local maven - // mavenLocal() + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. } } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/container/BackpackInventory.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/container/BackpackInventory.java index 846dcd9..b8d51fb 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/container/BackpackInventory.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/container/BackpackInventory.java @@ -25,20 +25,20 @@ public class BackpackInventory extends SimpleInventory { public static final BackpackInventory getInventory(BackpackScreenHandler handler, PlayerEntity player, ItemStack stack) { - return new BackpackInventory(init(stack).getTag().getCompound("backpack"), handler); + return new BackpackInventory(init(stack).getNbt().getCompound("backpack"), handler); } public BackpackInventory(ItemStack stack) { - this(init(stack).getTag().getCompound("backpack"), null); + this(init(stack).getNbt().getCompound("backpack"), null); } private final static ItemStack init(ItemStack stack) { if (stack != null) { - if (!stack.hasTag()) { - stack.setTag(new NbtCompound()); + if (!stack.hasNbt()) { + stack.setNbt(new NbtCompound()); } - if (!stack.getTag().contains("backpack")) { - stack.getTag().put("backpack", new NbtCompound()); + if (!stack.getNbt().contains("backpack")) { + stack.getNbt().put("backpack", new NbtCompound()); } } return stack; @@ -55,12 +55,12 @@ public class BackpackInventory extends SimpleInventory { super.onClose(player); ItemStack stack = player.getStackInHand(hand); if (stack != null) { - if (!stack.hasTag()) { - stack.setTag(new NbtCompound()); + if (!stack.hasNbt()) { + stack.setNbt(new NbtCompound()); } - stack.getTag().put("backpack", writeItemsToTag()); + stack.getNbt().put("backpack", writeItemsToTag()); } - player.getStackInHand(hand).setTag(stack.getTag()); + player.getStackInHand(hand).setNbt(stack.getNbt()); player.playSound(SoundEvents.BLOCK_WOOL_PLACE, SoundCategory.PLAYERS, 1f, 1f); } @@ -83,7 +83,7 @@ public class BackpackInventory extends SimpleInventory { if (!(itemStack == null) && !itemStack.isEmpty()) { NbtCompound compoundTag = new NbtCompound(); compoundTag.putInt("slot", i); - itemStack.setTag(compoundTag); + itemStack.setNbt(compoundTag); listTag.add(compoundTag); } } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/container/BackpackScreen.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/container/BackpackScreen.java index eba7ac5..01b62f5 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/container/BackpackScreen.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/container/BackpackScreen.java @@ -1,7 +1,5 @@ package de.jottyfan.minecraft.quickiefabric.container; -import com.mojang.blaze3d.platform.GlStateManager; - import de.jottyfan.minecraft.quickiefabric.init.RegistryManager; import de.jottyfan.minecraft.quickiefabric.items.ItemBackpack; import net.fabricmc.api.EnvType; @@ -55,7 +53,6 @@ public class BackpackScreen extends HandledScreen @Override protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) { -// GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); this.client.getTextureManager().bindTexture(TEXTURE); int guiX = this.titleX; int guiY = (this.height - this.containerHeight) / 2; diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/init/RegistryManager.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/init/RegistryManager.java index 1567e22..d0903d5 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/init/RegistryManager.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/init/RegistryManager.java @@ -6,15 +6,6 @@ import java.util.List; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockDownEntity; -import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockEastEntity; -import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockNorthEntity; -import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockSouthEntity; -import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockWestEntity; -import de.jottyfan.minecraft.quickiefabric.blockentity.EmptyLavaHoarderBlockEntity; -import de.jottyfan.minecraft.quickiefabric.blockentity.ItemHoarderBlockEntity; -import de.jottyfan.minecraft.quickiefabric.blockentity.MonsterHoarderBlockEntity; -import de.jottyfan.minecraft.quickiefabric.blockentity.QuickieFabricBlockEntity; import de.jottyfan.minecraft.quickiefabric.blocks.QuickieBlocks; import de.jottyfan.minecraft.quickiefabric.container.BackpackScreenHandler; import de.jottyfan.minecraft.quickiefabric.event.BreakBlockCallback; @@ -29,9 +20,6 @@ import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.block.ComposterBlock; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.block.entity.BlockEntityType.Builder; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; @@ -51,6 +39,7 @@ import net.minecraft.world.gen.decorator.RangeDecoratorConfig; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.OreFeatureConfig; +import net.minecraft.world.gen.heightprovider.UniformHeightProvider; /** * @@ -69,32 +58,32 @@ public class RegistryManager { public static final ConfiguredFeature FEATURE_ORENETHERSULPHOR = Feature.ORE .configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_NETHER, QuickieBlocks.ORE_NETHER_SULPHOR.getDefaultState(), 24)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(YOffset.aboveBottom(0), YOffset.belowTop(128))).spreadHorizontally().repeat(10)); - + .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(UniformHeightProvider.create(YOffset.aboveBottom(0), YOffset.belowTop(128)))).spreadHorizontally().repeat(10)); + public static final ConfiguredFeature FEATURE_ORESALPETER = Feature.ORE .configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, QuickieBlocks.ORE_SALPETER.getDefaultState(), 12)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(YOffset.aboveBottom(0), YOffset.belowTop(128)))).spreadHorizontally().repeat(10); + .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(UniformHeightProvider.create(YOffset.aboveBottom(0), YOffset.belowTop(128))))).spreadHorizontally().repeat(10); public static final ConfiguredFeature FEATURE_ORESULPHOR = Feature.ORE .configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, QuickieBlocks.ORE_SULPHOR.getDefaultState(), 16)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(YOffset.aboveBottom(32), YOffset.belowTop(255)))).spreadHorizontally().repeat(4); + .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(UniformHeightProvider.create(YOffset.aboveBottom(32), YOffset.belowTop(255))))).spreadHorizontally().repeat(4); public static final ConfiguredFeature FEATURE_DIRTSALPETER = Feature.ORE .configure( new OreFeatureConfig(new BlockMatchRuleTest(Blocks.DIRT), QuickieBlocks.DIRT_SALPETER.getDefaultState(), 3)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(YOffset.aboveBottom(0), YOffset.belowTop(255)))).spreadHorizontally().repeatRandomly(4); + .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(UniformHeightProvider.create(YOffset.aboveBottom(0), YOffset.belowTop(255))))).spreadHorizontally().repeatRandomly(4); public static final ConfiguredFeature FEATURE_SANDSALPETER = Feature.ORE .configure( new OreFeatureConfig(new BlockMatchRuleTest(Blocks.SAND), QuickieBlocks.SAND_SALPETER.getDefaultState(), 3)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(YOffset.aboveBottom(0), YOffset.belowTop(255)))).spreadHorizontally().repeatRandomly(4); + .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(UniformHeightProvider.create(YOffset.aboveBottom(0), YOffset.belowTop(255))))).spreadHorizontally().repeatRandomly(4); public static final ConfiguredFeature FEATURE_ORESANDSALPETER = Feature.ORE .configure(new OreFeatureConfig(new BlockMatchRuleTest(Blocks.SANDSTONE), QuickieBlocks.ORE_SAND_SALPETER.getDefaultState(), 3)) - .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(YOffset.aboveBottom(0), YOffset.belowTop(255)))).spreadHorizontally().repeatRandomly(4); + .decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(UniformHeightProvider.create(YOffset.aboveBottom(0), YOffset.belowTop(255))))).spreadHorizontally().repeatRandomly(4); public static final List> FEATURE_UNDERGROUND_ORES = Arrays.asList(FEATURE_ORESALPETER, FEATURE_ORESULPHOR, FEATURE_DIRTSALPETER, FEATURE_SANDSALPETER, FEATURE_ORESANDSALPETER); diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderPickaxe.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderPickaxe.java index 28f9e0a..741f41e 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderPickaxe.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolSpeedpowderPickaxe.java @@ -29,7 +29,7 @@ public class ToolSpeedpowderPickaxe extends PickaxeItem implements ToolRangeable @Override public HarvestRange getRange(ItemStack stack) { - NbtCompound tag = stack.getTag(); + NbtCompound tag = stack.getNbt(); int[] range = tag.getIntArray("range"); if (range.length < 3) { range = DEFAULT_HARVEST_RANGE; @@ -49,7 +49,7 @@ public class ToolSpeedpowderPickaxe extends PickaxeItem implements ToolRangeable } public void setPlusRange(ItemStack stack, Integer plusRange) { - NbtCompound tag = stack.getTag(); + NbtCompound tag = stack.getNbt(); int[] range = tag.getIntArray("range"); if (range.length < 3) { range = DEFAULT_HARVEST_RANGE;