From b2be25df7927c4413fb342f95e41ce5ec1b67634 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 3 Apr 2023 14:07:08 +0100 Subject: [PATCH 1/5] feat: right-click harvest support for cocoa beans and sweet berries https://github.com/FTBTeam/FTB-Mods-Issues/issues/742 --- .../dev/ftb/mods/ftbultimine/FTBUltimine.java | 2 +- .../ftbultimine/FTBUltiminePlayerData.java | 4 +-- .../mods/ftbultimine/RightClickHandlers.java | 32 ++++++++++++++----- .../mods/ftbultimine/shape/BlockMatcher.java | 10 +++--- .../ftbultimine/shape/ShapelessShape.java | 12 ++++--- 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltimine.java b/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltimine.java index d4442f5..1537101 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltimine.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltimine.java @@ -283,7 +283,7 @@ public EventResult blockRightClick(Player player, InteractionHand hand, BlockPos } boolean didWork = false; - if (FTBUltimineServerConfig.RIGHT_CLICK_HARVESTING.get() && shapeContext.matcher() == BlockMatcher.BUSH) { + if (FTBUltimineServerConfig.RIGHT_CLICK_HARVESTING.get() && shapeContext.matcher() == BlockMatcher.CROP_LIKE) { didWork = RightClickHandlers.cropHarvesting(serverPlayer, hand, clickPos, face, data); } else if (FTBUltimineServerConfig.RIGHT_CLICK_HOE.get() && serverPlayer.getItemInHand(hand).getItem() instanceof HoeItem) { didWork = RightClickHandlers.farmlandConversion(serverPlayer, hand, clickPos, data); diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltiminePlayerData.java b/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltiminePlayerData.java index 8282e46..38110a2 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltiminePlayerData.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltiminePlayerData.java @@ -112,8 +112,8 @@ public ShapeContext updateBlocks(ServerPlayer player, BlockPos pos, Direction di BlockMatcher matcher; if (shape.getTagMatcher().actualCheck(origState, origState)) { matcher = shape.getTagMatcher(); - } else if (BlockMatcher.BUSH.actualCheck(origState, origState)) { - matcher = BlockMatcher.BUSH; + } else if (BlockMatcher.CROP_LIKE.actualCheck(origState, origState)) { + matcher = BlockMatcher.CROP_LIKE; } else { matcher = BlockMatcher.MATCH; } diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/RightClickHandlers.java b/common/src/main/java/dev/ftb/mods/ftbultimine/RightClickHandlers.java index eee4377..b5affbe 100644 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/RightClickHandlers.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/RightClickHandlers.java @@ -16,10 +16,7 @@ import net.minecraft.world.item.HoneycombItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.CropBlock; -import net.minecraft.world.level.block.WeatheringCopper; +import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.gameevent.GameEvent; @@ -149,20 +146,19 @@ static boolean cropHarvesting(ServerPlayer player, InteractionHand hand, BlockPo for (BlockPos pos : data.cachedBlocks) { BlockState state = player.level.getBlockState(pos); - if (state.getBlock() instanceof CropBlock cropBlock && cropBlock.isMaxAge(state)) { + if (isHarvestable(state)) { BlockEntity blockEntity = state.hasBlockEntity() ? player.level.getBlockEntity(pos) : null; List drops = Block.getDrops(state, (ServerLevel) player.level, pos, blockEntity, player, ItemStack.EMPTY); for (ItemStack stack : drops) { // should work for most if not all modded crop blocks, hopefully - if (Block.byItem(stack.getItem()) == cropBlock) { + if (Block.byItem(stack.getItem()) == state.getBlock() && consumesItemToReplant(state)) { stack.shrink(1); } - itemCollection.add(stack); } - player.level.setBlock(pos, cropBlock.getStateForAge(0), Block.UPDATE_ALL); + resetAge(player.level, pos, state); didWork = true; } } @@ -171,4 +167,24 @@ static boolean cropHarvesting(ServerPlayer player, InteractionHand hand, BlockPo return didWork; } + + private static boolean consumesItemToReplant(BlockState state) { + return state.getBlock() != Blocks.SWEET_BERRY_BUSH; + } + + private static boolean isHarvestable(BlockState state) { + return state.getBlock() instanceof CropBlock cropBlock && cropBlock.isMaxAge(state) + || state.getBlock() instanceof SweetBerryBushBlock && state.getValue(SweetBerryBushBlock.AGE) >= SweetBerryBushBlock.MAX_AGE + || state.getBlock() instanceof CocoaBlock && state.getValue(CocoaBlock.AGE) >= CocoaBlock.MAX_AGE; + } + + private static void resetAge(Level level, BlockPos pos, BlockState currentState) { + if (currentState.getBlock() instanceof CropBlock cropBlock) { + level.setBlock(pos, cropBlock.getStateForAge(0), Block.UPDATE_ALL); + } else if (currentState.getBlock() instanceof SweetBerryBushBlock) { + level.setBlock(pos, currentState.setValue(SweetBerryBushBlock.AGE, 1), Block.UPDATE_ALL); + } else if (currentState.getBlock() instanceof CocoaBlock) { + level.setBlock(pos, currentState.setValue(CocoaBlock.AGE, 0), Block.UPDATE_ALL); + } + } } diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/shape/BlockMatcher.java b/common/src/main/java/dev/ftb/mods/ftbultimine/shape/BlockMatcher.java index b0abdc0..d662996 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/shape/BlockMatcher.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/shape/BlockMatcher.java @@ -2,10 +2,7 @@ import dev.ftb.mods.ftbultimine.FTBUltimine; import dev.ftb.mods.ftbultimine.config.FTBUltimineServerConfig; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.BushBlock; -import net.minecraft.world.level.block.CropBlock; -import net.minecraft.world.level.block.SaplingBlock; +import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.state.BlockState; /** @@ -21,13 +18,16 @@ default boolean actualCheck(BlockState original, BlockState state) { BlockMatcher MATCH = (original, state) -> original.getBlock() == state.getBlock(); BlockMatcher TAGS_MATCH_SHAPELESS = FTBUltimineServerConfig.MERGE_TAGS_SHAPELESS::match; BlockMatcher TAGS_MATCH_SHAPED = FTBUltimineServerConfig.MERGE_TAGS_SHAPED::match; - BlockMatcher BUSH = (original, state) -> state.getBlock() instanceof BushBlock && getBushType(state.getBlock()) == getBushType(original.getBlock()); + BlockMatcher CROP_LIKE = (original, state) -> (state.getBlock() instanceof BushBlock || state.getBlock() instanceof CocoaBlock) + && getBushType(state.getBlock()) == getBushType(original.getBlock()); static int getBushType(Block block) { if (block instanceof CropBlock) { return 1; } else if (block instanceof SaplingBlock) { return 2; + } else if (block instanceof CocoaBlock) { + return 3; } return 0; diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/shape/ShapelessShape.java b/common/src/main/java/dev/ftb/mods/ftbultimine/shape/ShapelessShape.java index 2818f35..5fef3c7 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/shape/ShapelessShape.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/shape/ShapelessShape.java @@ -9,8 +9,10 @@ * @author LatvianModder */ public class ShapelessShape implements Shape { + // all blocks in 3x3x3 cube around the block private static final List NEIGHBOR_POSITIONS = new ArrayList<>(26); - private static final List NEIGHBOR_POSITIONS_PLANT = new ArrayList<>(24); + // all blocks in 5x5 square around block's Y-level, plus blocks directly above & below + private static final List NEIGHBOR_POSITIONS_PLANT = new ArrayList<>(26); static { for (int x = -1; x <= 1; x++) { @@ -25,6 +27,8 @@ public class ShapelessShape implements Shape { if (x != 0 || z != 0) NEIGHBOR_POSITIONS_PLANT.add(new BlockPos(x, 0, z)); } } + NEIGHBOR_POSITIONS_PLANT.add(new BlockPos(0, 1, 0)); + NEIGHBOR_POSITIONS_PLANT.add(new BlockPos(0, -1, 0)); } @Override @@ -40,7 +44,7 @@ public BlockMatcher getTagMatcher() { @Override public List getBlocks(ShapeContext context) { HashSet known = new HashSet<>(); - walk(context, known, context.matcher() == BlockMatcher.BUSH); + walk(context, known, context.matcher() == BlockMatcher.CROP_LIKE); List list = new ArrayList<>(known); list.sort(new EntityDistanceComparator(context.pos())); @@ -52,7 +56,7 @@ public List getBlocks(ShapeContext context) { return list; } - private void walk(ShapeContext context, HashSet known, boolean plant) { + private void walk(ShapeContext context, HashSet known, boolean cropLike) { Set traversed = new HashSet<>(); Deque openSet = new ArrayDeque<>(); openSet.add(context.pos()); @@ -66,7 +70,7 @@ private void walk(ShapeContext context, HashSet known, boolean plant) return; } - for (BlockPos side : plant ? NEIGHBOR_POSITIONS_PLANT : NEIGHBOR_POSITIONS) { + for (BlockPos side : cropLike ? NEIGHBOR_POSITIONS_PLANT : NEIGHBOR_POSITIONS) { BlockPos offset = ptr.offset(side); if (traversed.add(offset)) { From 2d84885f9fd4f959c7ed4806fdc73f0f9eb09d57 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 3 Apr 2023 14:07:23 +0100 Subject: [PATCH 2/5] build: update ftb library dep version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 967eb71..d5f6db5 100755 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ archives_base_name=ftb-ultimine mod_author=FTB Team minecraft_version=1.19.2 architectury_version=6.2.46 -ftb_library_version=1902.3.11-build.166 +ftb_library_version=1902.3.16-build.193 ftb_ranks_version=1902.1.14-build.70 fabric_loader_version=0.14.9 fabric_api_version=0.60.0+1.19.2 From adc71d5989b56f841c50b33ea8c73eeabe171b76 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 3 Apr 2023 14:09:45 +0100 Subject: [PATCH 3/5] build: version -> 1902.4.1, changelog updated --- CHANGELOG.md | 5 +++++ gradle.properties | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca70aee..5eedc84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1902.4.1] + +### Added +* Right-click ultimine harvesting now also works for Cocoa Beans and Sweet Berries + ## [1902.4.0] ### Added diff --git a/gradle.properties b/gradle.properties index d5f6db5..c5cf200 100755 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mod_version=1902.4.0 +mod_version=1902.4.1 maven_group=dev.ftb.mods mod_id=ftbultimine archives_base_name=ftb-ultimine From 646d6ca1476b41539261069ba12271d5281da894 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Thu, 15 Jun 2023 17:26:30 +0100 Subject: [PATCH 4/5] chore: ported to 1.20.1 --- build.gradle | 13 ++++-- .../dev/ftb/mods/ftbultimine/FTBUltimine.java | 24 +++++------ .../ftbultimine/FTBUltiminePlayerData.java | 19 ++++++--- .../mods/ftbultimine/RightClickHandlers.java | 42 +++++++++---------- .../mods/ftbultimine/client/EdgeCallback.java | 2 +- .../ftbultimine/client/FTBUltimineClient.java | 10 ++--- .../config/FTBUltimineClientConfig.java | 18 ++++---- .../config/FTBUltimineCommonConfig.java | 8 ++-- .../config/FTBUltimineServerConfig.java | 37 ++++++++-------- .../mods/ftbultimine/shape/ShapeContext.java | 2 +- .../mods/ftbultimine/utils/ShapeMerger.java | 21 +++++++++- fabric/build.gradle | 11 +++-- fabric/src/main/resources/fabric.mod.json | 11 +++-- forge/build.gradle | 12 ++++-- .../utils/forge/PlatformMethodsImpl.java | 2 +- forge/src/main/resources/META-INF/mods.toml | 14 +++---- gradle.properties | 22 ++++++---- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 2 +- 19 files changed, 157 insertions(+), 115 deletions(-) diff --git a/build.gradle b/build.gradle index bd71746..62e0c6d 100755 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false + id "dev.architectury.loom" version "1.2-SNAPSHOT" apply false } architectury { @@ -50,7 +50,14 @@ allprojects { } maven { - url "https://maven.saps.dev/minecraft" + url "https://maven.saps.dev/releases" + content { + includeGroup "dev.latvian.mods" + includeGroup "dev.ftb.mods" + } + } + maven { + url "https://maven.saps.dev/snapshots" content { includeGroup "dev.latvian.mods" includeGroup "dev.ftb.mods" @@ -63,4 +70,4 @@ allprojects { } } -task curseforgePublish \ No newline at end of file +task curseforgePublish diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltimine.java b/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltimine.java index 1537101..6ff33e6 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltimine.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltimine.java @@ -17,7 +17,7 @@ import dev.ftb.mods.ftbultimine.shape.*; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; @@ -62,13 +62,13 @@ public class FTBUltimine { private int tempBlockDroppedXp; private ItemCollection tempBlockDropsList; - public static final TagKey DENY_TAG = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(MOD_ID, "excluded_tools")); - public static final TagKey STRICT_DENY_TAG = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(MOD_ID, "excluded_tools/strict")); - public static final TagKey ALLOW_TAG = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(MOD_ID, "included_tools")); - public static final TagKey EXCLUDED_BLOCKS = TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(MOD_ID, "excluded_blocks")); + public static final TagKey DENY_TAG = TagKey.create(Registries.ITEM, new ResourceLocation(MOD_ID, "excluded_tools")); + public static final TagKey STRICT_DENY_TAG = TagKey.create(Registries.ITEM, new ResourceLocation(MOD_ID, "excluded_tools/strict")); + public static final TagKey ALLOW_TAG = TagKey.create(Registries.ITEM, new ResourceLocation(MOD_ID, "included_tools")); + public static final TagKey EXCLUDED_BLOCKS = TagKey.create(Registries.BLOCK, new ResourceLocation(MOD_ID, "excluded_blocks")); - public static final TagKey TILLABLE_TAG = TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(MOD_ID, "farmland_tillable")); - public static final TagKey FLATTENABLE_TAG = TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(MOD_ID, "shovel_flattenable")); + public static final TagKey TILLABLE_TAG = TagKey.create(Registries.BLOCK, new ResourceLocation(MOD_ID, "farmland_tillable")); + public static final TagKey FLATTENABLE_TAG = TagKey.create(Registries.BLOCK, new ResourceLocation(MOD_ID, "shovel_flattenable")); private static Predicate permissionOverride = player -> true; @@ -204,7 +204,7 @@ public EventResult blockBroken(Level world, BlockPos pos, BlockState state, Serv data.clearCache(); data.updateBlocks(player, pos, ((BlockHitResult) result).getDirection(), false, FTBUltimineServerConfig.getMaxBlocks(player)); - if (data.cachedBlocks == null || data.cachedBlocks.isEmpty()) { + if (!data.hasCachedPositions()) { return EventResult.pass(); } @@ -214,7 +214,7 @@ public EventResult blockBroken(Level world, BlockPos pos, BlockState state, Serv boolean hadItem = !player.getMainHandItem().isEmpty(); float baseSpeed = state.getDestroySpeed(world, pos); - for (BlockPos p : data.cachedBlocks) { + for (BlockPos p : data.cachedPositions()) { float destroySpeed = world.getBlockState(p).getDestroySpeed(world, p); if (!player.isCreative() && (destroySpeed < 0 || destroySpeed > baseSpeed)) { continue; @@ -243,10 +243,10 @@ public EventResult blockBroken(Level world, BlockPos pos, BlockState state, Serv isBreakingBlock = false; - tempBlockDropsList.drop(player.level, pos); + tempBlockDropsList.drop(player.level(), pos); if (tempBlockDroppedXp > 0) { - player.level.addFreshEntity(new ExperienceOrb(player.level, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, tempBlockDroppedXp)); + player.level().addFreshEntity(new ExperienceOrb(player.level(), pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, tempBlockDroppedXp)); } data.clearCache(); @@ -278,7 +278,7 @@ public EventResult blockRightClick(Player player, InteractionHand hand, BlockPos data.clearCache(); ShapeContext shapeContext = data.updateBlocks(serverPlayer, clickPos, blockHitResult.getDirection(), false, FTBUltimineServerConfig.getMaxBlocks(serverPlayer)); - if (shapeContext == null || !data.isPressed() || data.cachedBlocks == null || data.cachedBlocks.isEmpty()) { + if (shapeContext == null || !data.isPressed() || !data.hasCachedPositions()) { return EventResult.pass(); } diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltiminePlayerData.java b/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltiminePlayerData.java index 38110a2..f9361da 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltiminePlayerData.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltiminePlayerData.java @@ -14,6 +14,7 @@ import net.minecraft.world.phys.HitResult; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.UUID; @@ -26,9 +27,9 @@ public class FTBUltiminePlayerData { private boolean pressed = false; private int shapeIndex = 0; - public BlockPos cachedPos; - public Direction cachedDirection; - public List cachedBlocks; + private BlockPos cachedPos; + private Direction cachedDirection; + private List cachedBlocks; public FTBUltiminePlayerData(UUID i) { id = i; @@ -48,6 +49,14 @@ public void setPressed(boolean pressed) { this.pressed = pressed; } + public boolean hasCachedPositions() { + return cachedBlocks != null && !cachedBlocks.isEmpty(); + } + + public Collection cachedPositions() { + return cachedBlocks; + } + public static HitResult rayTrace(ServerPlayer player) { double distance = PlatformMethods.reach(player); return player.pick(player.isCreative() ? distance + 0.5D : distance, 1F, false); @@ -108,7 +117,7 @@ public ShapeContext updateBlocks(ServerPlayer player, BlockPos pos, Direction di if (maxBlocks <= 0) { cachedBlocks = Collections.emptyList(); } else { - BlockState origState = player.level.getBlockState(cachedPos); + BlockState origState = player.level().getBlockState(cachedPos); BlockMatcher matcher; if (shape.getTagMatcher().actualCheck(origState, origState)) { matcher = shape.getTagMatcher(); @@ -117,7 +126,7 @@ public ShapeContext updateBlocks(ServerPlayer player, BlockPos pos, Direction di } else { matcher = BlockMatcher.MATCH; } - context = new ShapeContext(player, cachedPos, cachedDirection, player.level.getBlockState(cachedPos), matcher, maxBlocks); + context = new ShapeContext(player, cachedPos, cachedDirection, player.level().getBlockState(cachedPos), matcher, maxBlocks); cachedBlocks = shape.getBlocks(context); } diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/RightClickHandlers.java b/common/src/main/java/dev/ftb/mods/ftbultimine/RightClickHandlers.java index b5affbe..1c841d0 100644 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/RightClickHandlers.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/RightClickHandlers.java @@ -30,13 +30,13 @@ public class RightClickHandlers { static boolean axeStripping(ServerPlayer player, InteractionHand hand, BlockPos clickPos, FTBUltiminePlayerData data) { Set sounds = new HashSet<>(); BrokenItemHandler brokenItemHandler = new BrokenItemHandler(); - Level level = player.getLevel(); + Level level = player.level(); ItemStack itemStack = player.getItemInHand(hand); AxeItemAccess axeItemAccess = (AxeItemAccess) itemStack.getItem(); - for (BlockPos pos : data.cachedBlocks) { - BlockState state = player.level.getBlockState(pos); + for (BlockPos pos : data.cachedPositions()) { + BlockState state = player.level().getBlockState(pos); Optional stripping = axeItemAccess.invokeGetStripped(state); Optional scraping = WeatheringCopper.getPrevious(state); @@ -74,22 +74,22 @@ static boolean shovelFlattening(ServerPlayer player, InteractionHand hand, Block boolean didWork = false; BrokenItemHandler brokenItemHandler = new BrokenItemHandler(); - for (BlockPos pos : data.cachedBlocks) { - if (!player.level.getBlockState(pos.above()).isAir()) { + for (BlockPos pos : data.cachedPositions()) { + if (!player.level().getBlockState(pos.above()).isAir()) { continue; } - BlockState state = player.level.getBlockState(pos); + BlockState state = player.level().getBlockState(pos); BlockState newState = ShovelItemAccess.getFlattenables().get(state.getBlock()); if (newState == null && state.is(FTBUltimine.FLATTENABLE_TAG)) { newState = Blocks.DIRT_PATH.defaultBlockState(); } if (newState != null) { - player.level.setBlock(pos, newState, Block.UPDATE_ALL_IMMEDIATE); + player.level().setBlock(pos, newState, Block.UPDATE_ALL_IMMEDIATE); didWork = true; player.getMainHandItem().hurtAndBreak(1, player, brokenItemHandler); - player.getLevel().gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, newState)); + player.level().gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, newState)); if (brokenItemHandler.isBroken || player.getFoodData().getFoodLevel() <= 0) { break; } @@ -99,7 +99,7 @@ static boolean shovelFlattening(ServerPlayer player, InteractionHand hand, Block //noinspection ConstantConditions if (didWork) { // suppress warning: didWork only looks false due to mixin - player.level.playSound(player, clickPos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1F, 1F); + player.level().playSound(player, clickPos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1F, 1F); return true; } @@ -110,14 +110,14 @@ static boolean farmlandConversion(ServerPlayer player, InteractionHand hand, Blo boolean didWork = false; BrokenItemHandler brokenItemHandler = new BrokenItemHandler(); - for (BlockPos pos : data.cachedBlocks) { - if (!player.level.getBlockState(pos.above()).isAir()) { + for (BlockPos pos : data.cachedPositions()) { + if (!player.level().getBlockState(pos.above()).isAir()) { continue; } - BlockState state = player.level.getBlockState(pos); + BlockState state = player.level().getBlockState(pos); if (state.is(FTBUltimine.TILLABLE_TAG)) { - player.level.setBlock(pos, Blocks.FARMLAND.defaultBlockState(), Block.UPDATE_ALL_IMMEDIATE); - player.getLevel().gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, Blocks.FARMLAND.defaultBlockState())); + player.level().setBlock(pos, Blocks.FARMLAND.defaultBlockState(), Block.UPDATE_ALL_IMMEDIATE); + player.level().gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, Blocks.FARMLAND.defaultBlockState())); didWork = true; if (!player.isCreative()) { @@ -131,7 +131,7 @@ static boolean farmlandConversion(ServerPlayer player, InteractionHand hand, Blo } if (didWork) { - player.level.playSound(player, clickPos, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1F, 1F); + player.level().playSound(player, clickPos, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1F, 1F); return true; } @@ -143,12 +143,12 @@ static boolean cropHarvesting(ServerPlayer player, InteractionHand hand, BlockPo ItemCollection itemCollection = new ItemCollection(); - for (BlockPos pos : data.cachedBlocks) { - BlockState state = player.level.getBlockState(pos); + for (BlockPos pos : data.cachedPositions()) { + BlockState state = player.level().getBlockState(pos); if (isHarvestable(state)) { - BlockEntity blockEntity = state.hasBlockEntity() ? player.level.getBlockEntity(pos) : null; - List drops = Block.getDrops(state, (ServerLevel) player.level, pos, blockEntity, player, ItemStack.EMPTY); + BlockEntity blockEntity = state.hasBlockEntity() ? player.level().getBlockEntity(pos) : null; + List drops = Block.getDrops(state, (ServerLevel) player.level(), pos, blockEntity, player, ItemStack.EMPTY); for (ItemStack stack : drops) { // should work for most if not all modded crop blocks, hopefully @@ -158,12 +158,12 @@ static boolean cropHarvesting(ServerPlayer player, InteractionHand hand, BlockPo itemCollection.add(stack); } - resetAge(player.level, pos, state); + resetAge(player.level(), pos, state); didWork = true; } } - itemCollection.drop(player.level, face == null ? clickPos : clickPos.relative(face)); + itemCollection.drop(player.level(), face == null ? clickPos : clickPos.relative(face)); return didWork; } diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/client/EdgeCallback.java b/common/src/main/java/dev/ftb/mods/ftbultimine/client/EdgeCallback.java index 033b7b6..3ce88dc 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/client/EdgeCallback.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/client/EdgeCallback.java @@ -1,9 +1,9 @@ package dev.ftb.mods.ftbultimine.client; import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.math.Matrix4f; import net.minecraft.core.BlockPos; import net.minecraft.world.phys.shapes.Shapes; +import org.joml.Matrix4f; /** * @author LatvianModder diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/client/FTBUltimineClient.java b/common/src/main/java/dev/ftb/mods/ftbultimine/client/FTBUltimineClient.java index 1ee6d23..c4cc67f 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/client/FTBUltimineClient.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/client/FTBUltimineClient.java @@ -5,7 +5,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix4f; import dev.architectury.event.EventResult; import dev.architectury.event.events.client.ClientGuiEvent; import dev.architectury.event.events.client.ClientLifecycleEvent; @@ -26,7 +25,7 @@ import net.minecraft.client.Camera; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -38,6 +37,7 @@ import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; +import org.joml.Matrix4f; import org.lwjgl.glfw.GLFW; import java.util.*; @@ -232,7 +232,7 @@ public void info(RenderGameOverlayEvent.Text event) } }*/ - public void renderGameOverlay(PoseStack matrices, float tickDelta) { + public void renderGameOverlay(GuiGraphics graphics, float tickDelta) { if (pressed) { RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); @@ -245,8 +245,8 @@ public void renderGameOverlay(PoseStack matrices, float tickDelta) { for (MutableComponent msg : list) { FormattedCharSequence formatted = msg.getVisualOrderText(); - GuiComponent.fill(matrices, 1, top - 1, 2 + minecraft.font.width(formatted) + 1, top + minecraft.font.lineHeight - 1, 0xAA_2E3440); - minecraft.font.drawShadow(matrices, formatted, 2, top, 0xECEFF4); + graphics.fill(1, top - 1, 2 + minecraft.font.width(formatted) + 1, top + minecraft.font.lineHeight - 1, 0xAA_2E3440); + graphics.drawString(minecraft.font, formatted, 2, top, 0xECEFF4, true); top += minecraft.font.lineHeight; } } diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/config/FTBUltimineClientConfig.java b/common/src/main/java/dev/ftb/mods/ftbultimine/config/FTBUltimineClientConfig.java index 0e925d4..52034fb 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/config/FTBUltimineClientConfig.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/config/FTBUltimineClientConfig.java @@ -19,17 +19,17 @@ public interface FTBUltimineClientConfig { "This file is meant for users to control Ultimine's clientside behaviour and rendering.", "Changes to this file require you to reload the world"); - IntValue xOffset = CONFIG.getInt("x_offset", -1) + IntValue xOffset = CONFIG.addInt("x_offset", -1) .comment("Manual x offset of FTB Ultimine overlay, required for some modpacks"); - IntValue shapeMenuContextLines = CONFIG.getInt("shape_menu_context_lines", 2) + IntValue shapeMenuContextLines = CONFIG.addInt("shape_menu_context_lines", 2) .range(1, 5) .comment("When displaying the shape selection menu by holding the Ultimine key", "and sneaking at the same time, the number of shape names to display", "above and below the selected shape"); - BooleanValue requireSneakForMenu = CONFIG.getBoolean("require_sneak_for_menu", true) + BooleanValue requireSneakForMenu = CONFIG.addBoolean("require_sneak_for_menu", true) .comment("When holding the Ultimine key, must the player also be sneaking to show the shapes menu?"); - IntValue renderOutline = CONFIG.getInt("render_outline", 256) + IntValue renderOutline = CONFIG.addInt("render_outline", 256) .range(0, Integer.MAX_VALUE) .comment("Maximum number of blocks the white outline should be rendered for", "Keep in mind this may get *very* laggy for large amounts of blocks!"); @@ -39,15 +39,13 @@ static void load() { } static ConfigGroup getConfigGroup() { - ConfigGroup group = new ConfigGroup(MOD_ID + ".client_settings"); - - CONFIG.createClientConfig(group); - - group.savedCallback = accepted -> { + ConfigGroup group = new ConfigGroup(MOD_ID + ".client_settings", accepted -> { if (accepted) { CONFIG.save(Platform.getGameFolder().resolve("local/" + MOD_ID + "-client.snbt")); } - }; + }); + CONFIG.createClientConfig(group); + return group; } diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/config/FTBUltimineCommonConfig.java b/common/src/main/java/dev/ftb/mods/ftbultimine/config/FTBUltimineCommonConfig.java index ec30cb7..ed5f258 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/config/FTBUltimineCommonConfig.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/config/FTBUltimineCommonConfig.java @@ -22,18 +22,18 @@ public interface FTBUltimineCommonConfig { "This file is used to control instance (e.g. modpack) specific things like mod integrations.", "Changes to this file require you to restart the game!"); - IntValue PREVENT_TOOL_BREAK = CONFIG.getInt("prevent_tool_break", 0, 0, 100) + IntValue PREVENT_TOOL_BREAK = CONFIG.addInt("prevent_tool_break", 0, 0, 100) .comment("This will stop mining if tool reaches X durability. It's possible it won't work with special tool types."); -// BooleanValue USE_TRINKET = CONFIG.getBoolean("use_trinket", false) +// BooleanValue USE_TRINKET = CONFIG.addBoolean("use_trinket", false) // .comment("(This only works if the mod 'Lost Trinkets' is installed!)", // "Adds a custom 'Ultiminer' trinket players will need to activate to be able to use Ultimine.", // "Make sure you disable the 'Octopick' trinket if this is enabled!"); - BooleanValue CANCEL_ON_BLOCK_BREAK_FAIL = CONFIG.getBoolean("cancel_on_block_break_fail", false) + BooleanValue CANCEL_ON_BLOCK_BREAK_FAIL = CONFIG.addBoolean("cancel_on_block_break_fail", false) .comment("This is an advanced option, that you better leave alone This will stop ultimining on first block that it can't mine, rather than skipping it."); - BooleanValue REQUIRE_TOOL = CONFIG.getBoolean("require_tool", false) + BooleanValue REQUIRE_TOOL = CONFIG.addBoolean("require_tool", false) .comment("Require damageable tools or items added to ftbultimine:tools tag to ultimine."); static void load() { diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/config/FTBUltimineServerConfig.java b/common/src/main/java/dev/ftb/mods/ftbultimine/config/FTBUltimineServerConfig.java index 900aff2..f800659 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/config/FTBUltimineServerConfig.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/config/FTBUltimineServerConfig.java @@ -7,6 +7,8 @@ import dev.ftb.mods.ftbultimine.integration.FTBRanksIntegration; import dev.ftb.mods.ftbultimine.net.SyncConfigToServerPacket; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; @@ -36,11 +38,11 @@ public interface FTBUltimineServerConfig { "This file is meant for server administrators to control user behaviour.", "Changes in this file currently require a server restart to take effect"); - IntValue MAX_BLOCKS = CONFIG.getInt("max_blocks", 64) + IntValue MAX_BLOCKS = CONFIG.addInt("max_blocks", 64) .range(32768) .comment("Max amount of blocks that can be ultimined at once"); - DoubleValue EXHAUSTION_PER_BLOCK = CONFIG.getDouble("exhaustion_per_block", 20) + DoubleValue EXHAUSTION_PER_BLOCK = CONFIG.addDouble("exhaustion_per_block", 20) .range(10000) .comment("Hunger multiplied for each block mined with ultimine"); @@ -57,25 +59,25 @@ public interface FTBUltimineServerConfig { )), "These tags will be considered the same block when checking for blocks to Ultimine in shaped mining modes"); - IntValue PREVENT_TOOL_BREAK = CONFIG.getInt("prevent_tool_break", 0, 0, 100) + IntValue PREVENT_TOOL_BREAK = CONFIG.addInt("prevent_tool_break", 0, 0, 100) .comment("This will stop mining if tool reaches X durability. It's possible it won't work with special tool types."); - BooleanValue CANCEL_ON_BLOCK_BREAK_FAIL = CONFIG.getBoolean("cancel_on_block_break_fail", false) + BooleanValue CANCEL_ON_BLOCK_BREAK_FAIL = CONFIG.addBoolean("cancel_on_block_break_fail", false) .comment("This is an advanced option, that you better leave alone This will stop ultimining on first block that it can't mine, rather than skipping it."); - BooleanValue REQUIRE_TOOL = CONFIG.getBoolean("require_tool", false) + BooleanValue REQUIRE_TOOL = CONFIG.addBoolean("require_tool", false) .comment("Require a damageable tool, or an item in the ftbultimine:tools tag, to ultimine."); - BooleanValue RIGHT_CLICK_AXE = CONFIG.getBoolean("right_click_axe", true) + BooleanValue RIGHT_CLICK_AXE = CONFIG.addBoolean("right_click_axe", true) .comment("Right-click with an axe with the Ultimine key held to strip multiple logs and scrape/unwax copper blocks"); - BooleanValue RIGHT_CLICK_SHOVEL = CONFIG.getBoolean("right_click_shovel", true) + BooleanValue RIGHT_CLICK_SHOVEL = CONFIG.addBoolean("right_click_shovel", true) .comment("Right-click with a shovel with the Ultimine key held to flatten multiple grass/dirt blocks into dirt paths"); - BooleanValue RIGHT_CLICK_HOE = CONFIG.getBoolean("right_click_hoe", true) + BooleanValue RIGHT_CLICK_HOE = CONFIG.addBoolean("right_click_hoe", true) .comment("Right-click with a hoe with the Ultimine key held to till multiple grass/dirt blocks into farmland"); - BooleanValue RIGHT_CLICK_HARVESTING = CONFIG.getBoolean("right_click_harvesting", true) + BooleanValue RIGHT_CLICK_HARVESTING = CONFIG.addBoolean("right_click_harvesting", true) .comment("Right-click crops with the Ultimine key held to harvest multiple crop blocks"); -// BooleanValue USE_TRINKET = CONFIG.getBoolean("use_trinket", false) +// BooleanValue USE_TRINKET = CONFIG.addBoolean("use_trinket", false) // .comment("(This only works if the mod 'Lost Trinkets' is installed!)", // "Adds a custom 'Ultiminer' trinket players will need to activate to be able to use Ultimine.", // "Make sure you disable the 'Octopick' trinket if this is enabled!"); @@ -109,18 +111,15 @@ static void load(MinecraftServer server) { } static ConfigGroup getConfigGroup() { - ConfigGroup group = new ConfigGroup(MOD_ID + ".server_settings"); - - CONFIG.createClientConfig(group); - group.savedCallback = accepted -> { + ConfigGroup group = new ConfigGroup(MOD_ID + ".server_settings", accepted -> { if (accepted) { clearTagCache(); SNBTCompoundTag config = new SNBTCompoundTag(); FTBUltimineServerConfig.CONFIG.write(config); new SyncConfigToServerPacket(config).sendToServer(); } - }; - + }); + CONFIG.createClientConfig(group); return group; } @@ -140,7 +139,7 @@ class BlockTagsConfig { private boolean matchAny = false; public BlockTagsConfig(SNBTConfig parent, String name, List defaults, String... comment) { - this.value = parent.getStringList(name, defaults).comment(comment); + this.value = parent.addStringList(name, defaults).comment(comment); } public boolean match(BlockState original, BlockState toTest) { @@ -160,10 +159,10 @@ public Collection> getTags() { value.get().forEach(s -> { ResourceLocation rl = ResourceLocation.tryParse(s); if (rl != null) { - tags.add(TagKey.create(Registry.BLOCK_REGISTRY, rl)); + tags.add(TagKey.create(Registries.BLOCK, rl)); } else { Pattern pattern = regexFromGlobString(s); - Registry.BLOCK.getTags().forEach((tag) -> { + BuiltInRegistries.BLOCK.getTags().forEach((tag) -> { if (pattern.asPredicate().test(tag.getFirst().location().toString())) { tags.add(tag.getFirst()); } diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/shape/ShapeContext.java b/common/src/main/java/dev/ftb/mods/ftbultimine/shape/ShapeContext.java index df7fb45..d5e89c1 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/shape/ShapeContext.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/shape/ShapeContext.java @@ -15,7 +15,7 @@ public boolean check(BlockState state) { } public BlockState block(BlockPos pos) { - return player.level.getBlockState(pos); + return player.level().getBlockState(pos); } public boolean check(BlockPos pos) { diff --git a/common/src/main/java/dev/ftb/mods/ftbultimine/utils/ShapeMerger.java b/common/src/main/java/dev/ftb/mods/ftbultimine/utils/ShapeMerger.java index d1d5b69..fbd9b02 100755 --- a/common/src/main/java/dev/ftb/mods/ftbultimine/utils/ShapeMerger.java +++ b/common/src/main/java/dev/ftb/mods/ftbultimine/utils/ShapeMerger.java @@ -3,14 +3,18 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; +import it.unimi.dsi.fastutil.longs.Long2ObjectMap; +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; +import java.util.Arrays; import java.util.Collection; import java.util.Map; import java.util.Optional; +import java.util.stream.Collectors; /* * This class is based on Chisels and Bits' AABBCompressor, the original source for which can be found here: @@ -22,6 +26,15 @@ * Explicit permission was given to FTB by the original author of AABBCompressor to include this file in this project. */ public final class ShapeMerger { + private static final Long2ObjectMap BY_NORMAL = Arrays.stream(Direction.values()) + .collect(Collectors.toMap( + dir -> new BlockPos(dir.getNormal()).asLong(), + dir -> dir, + (dir, dir2) -> { + throw new IllegalArgumentException("Duplicate keys"); + }, Long2ObjectOpenHashMap::new) + ); + private double regionBuildingAxis = Double.NEGATIVE_INFINITY; private double faceBuildingAxis = Double.NEGATIVE_INFINITY; @@ -173,8 +186,8 @@ public static Collection merge(Collection positions, BlockPos or Optional moveNext = previousCenterPoint.map( v -> { Vec3 w = centerPoint.subtract(v); - BlockPos onPos = new BlockPos(w); - return Direction.fromNormal(onPos.getX(), onPos.getY(), onPos.getZ()); + BlockPos onPos = BlockPos.containing(w); + return dirFromNormal(onPos.getX(), onPos.getY(), onPos.getZ()); } ); @@ -199,4 +212,8 @@ public static Collection merge(Collection positions, BlockPos or }); return merger.getBoxes(); } + + private static Direction dirFromNormal(int pX, int pY, int pZ) { + return BY_NORMAL.get(BlockPos.asLong(pX, pY, pZ)); + } } \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle index b653201..5265634 100755 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -47,13 +47,18 @@ processResources { inputs.property "version", project.version filesMatching("fabric.mod.json") { - expand "version": project.version + expand "version": project.version, + "archversion": project.architectury_version, + "forgeversion": project.forge_version, + "forgeshortversion": project.forge_version.split("\\.")[0], + "mcversion": project.minecraft_version, + "ftblibraryversion": project.ftb_library_version.replaceAll("-SNAPSHOT", "") } } shadowJar { configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" + setArchiveClassifier("dev-shadow") } remapJar { @@ -64,7 +69,7 @@ remapJar { } jar { - classifier "dev" + setArchiveClassifier("dev") } components.java { diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 85667e5..a9a7351 100755 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -6,11 +6,11 @@ "name": "FTB Ultimine", "description": "Allows you to break multiple blocks at once.", "authors": [ - "LatvianModder" + "FTB Team" ], "contact": { "sources": "https://github.com/FTBTeam/FTB-Ultimine", - "issues": "https://github.com/FTBTeam/FTB-Ultimine/issues" + "issues": "https://go.ftb.team/support-mod-issues" }, "license": "All Rights Reserved", "environment": "*", @@ -24,9 +24,8 @@ ], "accessWidener": "ftbultimine.accesswidener", "depends": { - "fabricloader": ">=0.12.12", - "minecraft": ">=1.19.2", - "architectury": ">=6.2.46", - "ftblibrary": ">=1902.3.14-build.184" + "minecraft": "~${mcversion}", + "architectury": ">=${archversion}", + "ftblibrary": ">=${ftblibraryversion}" } } diff --git a/forge/build.gradle b/forge/build.gradle index 6eb3f46..170fbf7 100755 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -50,7 +50,12 @@ processResources { inputs.property "version", project.version filesMatching("META-INF/mods.toml") { - expand "version": project.version + expand "version": project.version, + "archversion": project.architectury_version, + "forgeversion": project.forge_version, + "forgeshortversion": project.forge_version.split("\\.")[0], + "mcversion": project.minecraft_version, + "ftblibraryversion": project.ftb_library_version.replaceAll("-SNAPSHOT", "") } } @@ -58,7 +63,7 @@ shadowJar { exclude "fabric.mod.json" configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" + setArchiveClassifier("dev-shadow") } remapJar { @@ -69,8 +74,7 @@ remapJar { } jar { - classifier "dev" -} + setArchiveClassifier("dev") } components.java { withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { diff --git a/forge/src/main/java/dev/ftb/mods/ftbultimine/utils/forge/PlatformMethodsImpl.java b/forge/src/main/java/dev/ftb/mods/ftbultimine/utils/forge/PlatformMethodsImpl.java index a26e850..7a5a144 100755 --- a/forge/src/main/java/dev/ftb/mods/ftbultimine/utils/forge/PlatformMethodsImpl.java +++ b/forge/src/main/java/dev/ftb/mods/ftbultimine/utils/forge/PlatformMethodsImpl.java @@ -5,6 +5,6 @@ public class PlatformMethodsImpl { public static double reach(ServerPlayer player) { - return player.getAttributeValue(ForgeMod.REACH_DISTANCE.get()); + return player.getAttributeValue(ForgeMod.BLOCK_REACH.get()); } } diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 0f1f5dc..d43abba 100755 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -1,13 +1,13 @@ modLoader = "javafml" -loaderVersion = "[43,)" -issueTrackerURL = "https://github.com/FTBTeam/FTB-Ultimine/issues" +loaderVersion = "[47,)" +issueTrackerURL = "https://go.ftb.team/support-mod-issues" license = "All Rights Reserved" [[mods]] modId = "ftbultimine" version = "${version}" displayName = "FTB Ultimine" -authors = "LatvianModder" +authors = "FTB Team" description = ''' Allows you to break multiple blocks at once ''' @@ -15,28 +15,28 @@ Allows you to break multiple blocks at once [[dependencies.ftbultimine]] modId = "forge" mandatory = true -versionRange = "[43,)" +versionRange = "[47,)" ordering = "NONE" side = "BOTH" [[dependencies.ftbultimine]] modId = "minecraft" mandatory = true -versionRange = "[1.19.2,)" +versionRange = "[${mcversion},)" ordering = "NONE" side = "BOTH" [[dependencies.ftbultimine]] modId = "architectury" mandatory = true -versionRange = "[6.2.46,)" +versionRange = "[${archversion},)" ordering = "NONE" side = "BOTH" [[dependencies.ftbultimine]] modId = "ftblibrary" mandatory = true -versionRange = "[1902.3.14-build.184,)" +versionRange = "[${ftblibraryversion},)" ordering = "NONE" side = "BOTH" diff --git a/gradle.properties b/gradle.properties index c5cf200..b4bed18 100755 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,21 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mod_version=1902.4.1 + +mod_version=2001.1.1 maven_group=dev.ftb.mods mod_id=ftbultimine archives_base_name=ftb-ultimine mod_author=FTB Team -minecraft_version=1.19.2 -architectury_version=6.2.46 -ftb_library_version=1902.3.16-build.193 -ftb_ranks_version=1902.1.14-build.70 -fabric_loader_version=0.14.9 -fabric_api_version=0.60.0+1.19.2 -forge_version=43.2.6 + +minecraft_version=1.20.1 +forge_version=47.0.1 +architectury_version=9.0.8 +fabric_loader_version=0.14.21 +fabric_api_version=0.83.1+1.20.1 + +ftb_library_version=2001.1.1-build.220-SNAPSHOT +ftb_ranks_version=2001.1.2-build.89-SNAPSHOT + curseforge_id_forge=386134 curseforge_id_fabric=448231 -curseforge_type=release +curseforge_type=alpha diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b72c1af..6985c87 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip \ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip diff --git a/settings.gradle b/settings.gradle index 926edf7..6879ce7 100755 --- a/settings.gradle +++ b/settings.gradle @@ -12,4 +12,4 @@ pluginManagement { include "common", "fabric", "forge" -rootProject.name = 'FTB-Ultimine-1.19' +rootProject.name = 'FTB-Ultimine-1.20.1' From 7353fb4246dd71768a4f97ab6c3d45a8e4a64977 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Thu, 15 Jun 2023 17:30:39 +0100 Subject: [PATCH 5/5] ci: update to new CI system --- .github/workflows/build.yml | 49 +++++++++-------------------------- .github/workflows/release.yml | 17 ++++++++++++ build.gradle | 3 +++ common/build.gradle | 17 ++++++------ fabric/build.gradle | 19 +++++++------- forge/build.gradle | 19 +++++++------- 6 files changed, 61 insertions(+), 63 deletions(-) mode change 100755 => 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml old mode 100755 new mode 100644 index 36d6285..5d4d795 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,48 +1,23 @@ -name: Java CI +name: Java CI - Build on Push on: push: - branches: - # main and dev versions for each mc ver here - - "1.19/main" - - "1.19/dev" + branches: [ main, dev, "1.*" ] workflow_dispatch: inputs: - norelease: - description: 'Do not publish' + skip_maven_publish: + description: 'Skip Maven publishing' required: true default: 'false' jobs: build: - runs-on: ubuntu-latest if: | - !contains(github.event.head_commit.message, '[ci skip]') - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 30 # Gets the last 30 commits so the changelog might work - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v1 - - name: Build and Publish with Gradle - uses: gradle/gradle-build-action@v2 - env: - FTB_MAVEN_TOKEN: ${{ secrets.FTB_MAVEN_TOKEN }} - SAPS_TOKEN: ${{ secrets.SAPS_TOKEN }} - with: - arguments: build publish --stacktrace --no-daemon - - name: Release to CurseForge - uses: gradle/gradle-build-action@v2 - if: | - contains(github.ref, 'main') && !contains(github.event.head_commit.message, '[norelease]') && github.event.inputs.norelease != 'true' - env: - GIT_COMMIT: ${{ github.event.after }} - GIT_PREVIOUS_COMMIT: ${{ github.event.before }} - CURSEFORGE_KEY: ${{ secrets.CURSEFORGE_KEY }} - with: - arguments: build curseforgePublish --stacktrace --no-daemon + !contains(github.event.head_commit.message, '[ciskip]') + uses: FTBTeam/mods-meta/.github/workflows/standard-release.yml@main + with: + curse-publish-task: "" + maven-snapshots: true + secrets: + ftb-maven-token: ${{ secrets.FTB_MAVEN_TOKEN }} + saps-token: ${{ secrets.SAPS_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7f875fc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,17 @@ +name: Java CI - Build Release + +on: + release: + types: [ published ] + +jobs: + build: + if: | + !contains(github.event.head_commit.message, '[ciskip]') + uses: FTBTeam/mods-meta/.github/workflows/standard-release.yml@main + with: + curse-publish-task: curseforge + secrets: + ftb-maven-token: ${{ secrets.FTB_MAVEN_TOKEN }} + saps-token: ${{ secrets.SAPS_TOKEN }} + curse-token: ${{ secrets.CURSEFORGE_KEY }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 62e0c6d..10c5854 100755 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,9 @@ allprojects { group = project.maven_group archivesBaseName = project.archives_base_name + // needs to be done AFTER version is set + apply from: "https://raw.githubusercontent.com/FTBTeam/mods-meta/main/gradle/publishing.gradle" + sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = 17 compileJava { diff --git a/common/build.gradle b/common/build.gradle index 53619b0..b45f6d6 100755 --- a/common/build.gradle +++ b/common/build.gradle @@ -27,27 +27,28 @@ publishing { publications { mavenCommon(MavenPublication) { artifactId = rootProject.archivesBaseName + version ftbPublishing.mavenVersion from components.java } } repositories { - if (ENV.FTB_MAVEN_TOKEN) { + if (ftbPublishing.ftbToken) { maven { - url "https://maven.ftb.dev/release" + url ftbPublishing.ftbURL credentials { - username = "ftb" - password = "${ENV.FTB_MAVEN_TOKEN}" + username = ftbPublishing.ftbUser + password = ftbPublishing.ftbToken } } } - if (ENV.SAPS_TOKEN) { + if (ftbPublishing.sapsToken) { maven { - url "https://maven.saps.dev/minecraft" + url ftbPublishing.sapsURL credentials { - username = "ftb" - password = "${ENV.SAPS_TOKEN}" + username = ftbPublishing.sapsUser + password = ftbPublishing.sapsToken } } } diff --git a/fabric/build.gradle b/fabric/build.gradle index 5265634..a770639 100755 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -100,29 +100,30 @@ if (ENV.CURSEFORGE_KEY) { publishing { publications { - mavenFabric(MavenPublication) { + mavenForge(MavenPublication) { artifactId = "${rootProject.archives_base_name}-${project.name}" + version ftbPublishing.mavenVersion from components.java } } repositories { - if (ENV.FTB_MAVEN_TOKEN) { + if (ftbPublishing.ftbToken) { maven { - url "https://maven.ftb.dev/release" + url ftbPublishing.ftbURL credentials { - username = "ftb" - password = "${ENV.FTB_MAVEN_TOKEN}" + username = ftbPublishing.ftbUser + password = ftbPublishing.ftbToken } } } - if (ENV.SAPS_TOKEN) { + if (ftbPublishing.sapsToken) { maven { - url "https://maven.saps.dev/minecraft" + url ftbPublishing.sapsURL credentials { - username = "ftb" - password = "${ENV.SAPS_TOKEN}" + username = ftbPublishing.sapsUser + password = ftbPublishing.sapsToken } } } diff --git a/forge/build.gradle b/forge/build.gradle index 170fbf7..26af565 100755 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -105,27 +105,28 @@ publishing { publications { mavenForge(MavenPublication) { artifactId = "${rootProject.archives_base_name}-${project.name}" - artifact(remapJar) + version ftbPublishing.mavenVersion + from components.java } } repositories { - if (ENV.FTB_MAVEN_TOKEN) { + if (ftbPublishing.ftbToken) { maven { - url "https://maven.ftb.dev/release" + url ftbPublishing.ftbURL credentials { - username = "ftb" - password = "${ENV.FTB_MAVEN_TOKEN}" + username = ftbPublishing.ftbUser + password = ftbPublishing.ftbToken } } } - if (ENV.SAPS_TOKEN) { + if (ftbPublishing.sapsToken) { maven { - url "https://maven.saps.dev/minecraft" + url ftbPublishing.sapsURL credentials { - username = "ftb" - password = "${ENV.SAPS_TOKEN}" + username = ftbPublishing.sapsUser + password = ftbPublishing.sapsToken } } }