Skip to content

Commit

Permalink
Merge pull request #134 from FTBTeam/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
desht authored Jun 16, 2023
2 parents dd20ae9 + 7353fb4 commit f4d3574
Show file tree
Hide file tree
Showing 25 changed files with 262 additions and 197 deletions.
49 changes: 12 additions & 37 deletions .github/workflows/build.yml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -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 }}
17 changes: 17 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -50,7 +53,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"
Expand All @@ -63,4 +73,4 @@ allprojects {
}
}

task curseforgePublish
task curseforgePublish
17 changes: 9 additions & 8 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
26 changes: 13 additions & 13 deletions common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltimine.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,13 +62,13 @@ public class FTBUltimine {
private int tempBlockDroppedXp;
private ItemCollection tempBlockDropsList;

public static final TagKey<Item> DENY_TAG = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(MOD_ID, "excluded_tools"));
public static final TagKey<Item> STRICT_DENY_TAG = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(MOD_ID, "excluded_tools/strict"));
public static final TagKey<Item> ALLOW_TAG = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(MOD_ID, "included_tools"));
public static final TagKey<Block> EXCLUDED_BLOCKS = TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(MOD_ID, "excluded_blocks"));
public static final TagKey<Item> DENY_TAG = TagKey.create(Registries.ITEM, new ResourceLocation(MOD_ID, "excluded_tools"));
public static final TagKey<Item> STRICT_DENY_TAG = TagKey.create(Registries.ITEM, new ResourceLocation(MOD_ID, "excluded_tools/strict"));
public static final TagKey<Item> ALLOW_TAG = TagKey.create(Registries.ITEM, new ResourceLocation(MOD_ID, "included_tools"));
public static final TagKey<Block> EXCLUDED_BLOCKS = TagKey.create(Registries.BLOCK, new ResourceLocation(MOD_ID, "excluded_blocks"));

public static final TagKey<Block> TILLABLE_TAG = TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(MOD_ID, "farmland_tillable"));
public static final TagKey<Block> FLATTENABLE_TAG = TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(MOD_ID, "shovel_flattenable"));
public static final TagKey<Block> TILLABLE_TAG = TagKey.create(Registries.BLOCK, new ResourceLocation(MOD_ID, "farmland_tillable"));
public static final TagKey<Block> FLATTENABLE_TAG = TagKey.create(Registries.BLOCK, new ResourceLocation(MOD_ID, "shovel_flattenable"));

private static Predicate<Player> permissionOverride = player -> true;

Expand Down Expand Up @@ -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();
}

Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -278,12 +278,12 @@ 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();
}

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,9 +27,9 @@ public class FTBUltiminePlayerData {
private boolean pressed = false;
private int shapeIndex = 0;

public BlockPos cachedPos;
public Direction cachedDirection;
public List<BlockPos> cachedBlocks;
private BlockPos cachedPos;
private Direction cachedDirection;
private List<BlockPos> cachedBlocks;

public FTBUltiminePlayerData(UUID i) {
id = i;
Expand All @@ -48,6 +49,14 @@ public void setPressed(boolean pressed) {
this.pressed = pressed;
}

public boolean hasCachedPositions() {
return cachedBlocks != null && !cachedBlocks.isEmpty();
}

public Collection<BlockPos> 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);
Expand Down Expand Up @@ -108,16 +117,16 @@ 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();
} 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;
}
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);
}

Expand Down
Loading

0 comments on commit f4d3574

Please sign in to comment.