Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: port to 1.21 #147

Merged
merged 1 commit into from
Jun 17, 2024
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
28 changes: 14 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
id "me.modmuss50.mod-publish-plugin" version "0.5.1"
}

architectury {
Expand Down Expand Up @@ -117,8 +117,8 @@ publishMods {
}

def fabricOptions = createOptions("fabric")
// def forgeOptions = createOptions("forge")
def neoForgeOptions = createOptions("neoforge")
// def forgeOptions = createOptions("forge")

def curseForgeOptions = curseforgeOptions {
accessToken = providers.environmentVariable("CURSEFORGE_KEY")
Expand All @@ -128,10 +128,18 @@ publishMods {
curseforge("curseforgeFabric") {
from(curseForgeOptions, fabricOptions)
projectId = curseforge_id_fabric
requires {slug = "fabric-api" }
requires {slug = "architectury-api" }
requires {slug = 'ftb-library-fabric' }
optional {slug = 'ftb-ranks-fabric' }
requires("fabric-api")
requires("architectury-api")
requires('ftb-library-fabric')
optional('ftb-ranks-fabric')
}

curseforge("curseforgeNeoForge") {
from(curseForgeOptions, neoForgeOptions)
projectId = curseforge_id_forge
requires("architectury-api")
requires('ftb-library-forge')
optional('ftb-ranks-forge')
}

// curseforge("curseforgeForge") {
Expand All @@ -141,12 +149,4 @@ publishMods {
// requires {slug = 'ftb-library-forge' }
// optional {slug = 'ftb-ranks-forge' }
// }

curseforge("curseforgeNeoForge") {
from(curseForgeOptions, neoForgeOptions)
projectId = curseforge_id_forge
requires {slug = "architectury-api" }
requires {slug = 'ftb-library-forge' }
optional {slug = 'ftb-ranks-forge' }
}
}
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
modApi "dev.architectury:architectury:${rootProject.architectury_api_version}"
modApi "dev.ftb.mods:ftb-library:${rootProject.ftb_library_version}"
modApi "dev.ftb.mods:ftb-ranks:${rootProject.ftb_ranks_version}"
}
Expand Down

This file was deleted.

16 changes: 8 additions & 8 deletions common/src/main/java/dev/ftb/mods/ftbultimine/FTBUltimine.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ public class FTBUltimine {
private int tempBlockDroppedXp;
private ItemCollection tempBlockDropsList;

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<Item> DENY_TAG = TagKey.create(Registries.ITEM, FTBUltimine.rl("excluded_tools"));
public static final TagKey<Item> STRICT_DENY_TAG = TagKey.create(Registries.ITEM, FTBUltimine.rl("excluded_tools/strict"));
public static final TagKey<Item> ALLOW_TAG = TagKey.create(Registries.ITEM, FTBUltimine.rl("included_tools"));

public static final TagKey<Block> EXCLUDED_BLOCKS = TagKey.create(Registries.BLOCK, new ResourceLocation(MOD_ID, "excluded_blocks"));
public static final TagKey<Block> BLOCK_WHITELIST = TagKey.create(Registries.BLOCK, new ResourceLocation(MOD_ID, "block_whitelist"));
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"));
public static final TagKey<Block> EXCLUDED_BLOCKS = TagKey.create(Registries.BLOCK, FTBUltimine.rl("excluded_blocks"));
public static final TagKey<Block> BLOCK_WHITELIST = TagKey.create(Registries.BLOCK, FTBUltimine.rl("block_whitelist"));
public static final TagKey<Block> TILLABLE_TAG = TagKey.create(Registries.BLOCK, FTBUltimine.rl("farmland_tillable"));
public static final TagKey<Block> FLATTENABLE_TAG = TagKey.create(Registries.BLOCK, FTBUltimine.rl("shovel_flattenable"));

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

Expand Down Expand Up @@ -358,7 +358,7 @@ public EventResult entityJoinedWorld(Entity entity, Level level) {
}

public static ResourceLocation rl(String path) {
return new ResourceLocation(MOD_ID, path);
return ResourceLocation.fromNamespaceAndPath(MOD_ID, path);
}

public static boolean isTooExhausted(ServerPlayer player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.HoneycombItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
Expand All @@ -29,7 +30,6 @@
public class RightClickHandlers {
static int axeStripping(ServerPlayer player, InteractionHand hand, BlockPos clickPos, FTBUltiminePlayerData data) {
Set<SoundEvent> sounds = new HashSet<>();
BrokenItemHandler brokenItemHandler = new BrokenItemHandler(player);
Level level = player.level();

ItemStack itemStack = player.getItemInHand(hand);
Expand Down Expand Up @@ -59,9 +59,9 @@ static int axeStripping(ServerPlayer player, InteractionHand hand, BlockPos clic
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(player, pos, itemStack);
level.setBlock(pos, actual.get(), Block.UPDATE_ALL_IMMEDIATE);
level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, actual.get()));
itemStack.hurtAndBreak(1, level.random, player, brokenItemHandler);

if (brokenItemHandler.isBroken) {
var result = hurtItemAndCheckIfBroken(player, hand);
if (result) {
break;
}
}
Expand All @@ -72,7 +72,6 @@ static int axeStripping(ServerPlayer player, InteractionHand hand, BlockPos clic

static int shovelFlattening(ServerPlayer player, InteractionHand hand, BlockPos clickPos, FTBUltiminePlayerData data) {
int didWork = 0;
BrokenItemHandler brokenItemHandler = new BrokenItemHandler(player);

for (BlockPos pos : data.cachedPositions()) {
if (!player.level().getBlockState(pos.above()).isAir()) {
Expand All @@ -88,9 +87,10 @@ static int shovelFlattening(ServerPlayer player, InteractionHand hand, BlockPos
player.level().setBlock(pos, newState, Block.UPDATE_ALL_IMMEDIATE);
didWork++;

player.getMainHandItem().hurtAndBreak(1, player.getRandom(), player, brokenItemHandler);
var result = hurtItemAndCheckIfBroken(player, hand);
player.level().gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, newState));
if (brokenItemHandler.isBroken || player.getFoodData().getFoodLevel() <= 0) {

if (result || player.getFoodData().getFoodLevel() <= 0) {
break;
}
}
Expand All @@ -105,9 +105,14 @@ static int shovelFlattening(ServerPlayer player, InteractionHand hand, BlockPos
return didWork;
}

static boolean hurtItemAndCheckIfBroken(ServerPlayer player, InteractionHand hand) {
ItemStack itemStack = player.getItemInHand(hand);
itemStack.hurtAndBreak(1, player, hand == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND);
return itemStack.isEmpty();
}

static int farmlandConversion(ServerPlayer player, InteractionHand hand, BlockPos clickPos, FTBUltiminePlayerData data) {
int clicked = 0;
BrokenItemHandler brokenItemHandler = new BrokenItemHandler(player);

for (BlockPos pos : data.cachedPositions()) {
if (!player.level().getBlockState(pos.above()).isAir()) {
Expand All @@ -121,8 +126,9 @@ static int farmlandConversion(ServerPlayer player, InteractionHand hand, BlockPo

if (!player.isCreative()) {
player.causeFoodExhaustion((float) (FTBUltimineServerConfig.EXHAUSTION_PER_BLOCK.get() * 0.005D));
player.getMainHandItem().hurtAndBreak(1, player.getRandom(), player, brokenItemHandler);
if (brokenItemHandler.isBroken || FTBUltimine.isTooExhausted(player)) {
var result = hurtItemAndCheckIfBroken(player, hand);

if (result || FTBUltimine.isTooExhausted(player)) {
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public EdgeCallback(BufferBuilder b, Matrix4f m, BlockPos p, int a) {

@Override
public void consume(double x1, double y1, double z1, double x2, double y2, double z2) {
buffer.vertex(matrix, (float) (x1 + pos.getX()), (float) (y1 + pos.getY()), (float) (z1 + pos.getZ())).color(255, 255, 255, alpha).endVertex();
buffer.vertex(matrix, (float) (x2 + pos.getX()), (float) (y2 + pos.getY()), (float) (z2 + pos.getZ())).color(255, 255, 255, alpha).endVertex();
buffer.addVertex(matrix, (float) (x1 + pos.getX()), (float) (y1 + pos.getY()), (float) (z1 + pos.getZ())).setColor(255, 255, 255, alpha);
buffer.addVertex(matrix, (float) (x2 + pos.getX()), (float) (y2 + pos.getY()), (float) (z2 + pos.getZ())).setColor(255, 255, 255, alpha);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import dev.ftb.mods.ftbultimine.utils.ShapeMerger;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Camera;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
Expand Down Expand Up @@ -123,17 +124,17 @@ public void renderInGame(PoseStack stack) {
VertexConsumer buffer = mc.renderBuffers().bufferSource().getBuffer(UltimineRenderTypes.LINES_NORMAL);

for (CachedEdge edge : cachedEdges) {
buffer.vertex(matrix, edge.x1, edge.y1, edge.z1).color(255, 255, 255, 255).endVertex();
buffer.vertex(matrix, edge.x2, edge.y2, edge.z2).color(255, 255, 255, 255).endVertex();
buffer.addVertex(matrix, edge.x1, edge.y1, edge.z1).setColor(255, 255, 255, 255);
buffer.addVertex(matrix, edge.x2, edge.y2, edge.z2).setColor(255, 255, 255, 255);
}

mc.renderBuffers().bufferSource().endBatch(UltimineRenderTypes.LINES_NORMAL);

VertexConsumer buffer2 = mc.renderBuffers().bufferSource().getBuffer(UltimineRenderTypes.LINES_TRANSPARENT);

for (CachedEdge edge : cachedEdges) {
buffer2.vertex(matrix, edge.x1, edge.y1, edge.z1).color(255, 255, 255, 30).endVertex();
buffer2.vertex(matrix, edge.x2, edge.y2, edge.z2).color(255, 255, 255, 30).endVertex();
buffer2.addVertex(matrix, edge.x1, edge.y1, edge.z1).setColor(255, 255, 255, 30);
buffer2.addVertex(matrix, edge.x2, edge.y2, edge.z2).setColor(255, 255, 255, 30);
}

mc.renderBuffers().bufferSource().endBatch(UltimineRenderTypes.LINES_TRANSPARENT);
Expand Down Expand Up @@ -243,7 +244,7 @@ public void info(RenderGameOverlayEvent.Text event)
}
}*/

public void renderGameOverlay(GuiGraphics graphics, float tickDelta) {
public void renderGameOverlay(GuiGraphics graphics, DeltaTracker tickDelta) {
if (pressed) {
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
Expand Down
6 changes: 2 additions & 4 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
modApi "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"

modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_api_version}"

modApi("dev.ftb.mods:ftb-library-fabric:${rootProject.ftb_library_version}") { transitive = false }
modApi("dev.ftb.mods:ftb-ranks-fabric:${rootProject.ftb_ranks_version}") { transitive = false }
Expand All @@ -45,9 +45,7 @@ processResources {

filesMatching("fabric.mod.json") {
expand "version": project.version,
"archversion": project.architectury_version,
"forgeversion": project.forge_version,
"forgeshortversion": project.forge_version.split("\\.")[0],
"archversion": project.architectury_api_version,
"mcversion": project.minecraft_version,
"ftblibraryversion": project.ftb_library_version
}
Expand Down
4 changes: 2 additions & 2 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ artifacts {
dependencies {
forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}"

modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
modApi "dev.architectury:architectury-forge:${rootProject.architectury_api_version}"
modApi("dev.ftb.mods:ftb-library-forge:${rootProject.ftb_library_version}") { transitive = false }
modApi("dev.ftb.mods:ftb-ranks-forge:${rootProject.ftb_ranks_version}") { transitive = false }

Expand All @@ -49,7 +49,7 @@ processResources {

filesMatching("META-INF/mods.toml") {
expand "version": project.version,
"archversion": project.architectury_version,
"archversion": project.architectury_api_version,
"forgeversion": project.forge_version,
"forgeshortversion": project.forge_version.split("\\.")[0],
"mcversion": project.minecraft_version,
Expand Down
22 changes: 12 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

mod_version=2006.1.0
maven_group=dev.ftb.mods
mod_id=ftbultimine
archives_base_name=ftb-ultimine
readable_name=FTB Ultimine
mod_author=FTB Team

minecraft_version=1.20.6
mod_version=2100.1.0
minecraft_version=1.21

forge_version=50.0.9
neoforge_version=20.6.100-beta
neoforge_loader_version=1
fabric_loader_version=0.15.10
fabric_api_version=0.99.0+1.20.6
architectury_version=12.1.3
#forge_version=50.0.9
neoforge_version=21.0.10-beta

ftb_library_version=2006.1.1
ftb_ranks_version=2006.1.0
# https://maven.neoforged.net/#/releases/net/neoforged/fancymodloader/loader
neoforge_loader_version=4
fabric_loader_version=0.15.11
fabric_api_version=0.100.1+1.21
architectury_api_version=13.0.1

ftb_library_version=2100.1.0-SNAPSHOT
ftb_ranks_version=2100.1.0-SNAPSHOT

curseforge_id_forge=386134
curseforge_id_fabric=448231
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
4 changes: 2 additions & 2 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repositories {

dependencies {
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"
modApi "dev.architectury:architectury-neoforge:${rootProject.architectury_version}"
modApi "dev.architectury:architectury-neoforge:${rootProject.architectury_api_version}"

modApi("dev.ftb.mods:ftb-library-neoforge:${rootProject.ftb_library_version}") { transitive = false }
modApi("dev.ftb.mods:ftb-ranks-neoforge:${rootProject.ftb_ranks_version}") { transitive = false }
Expand All @@ -44,7 +44,7 @@ processResources {

filesMatching("META-INF/neoforge.mods.toml") {
expand "version": project.version,
"archversion": project.architectury_version,
"archversion": project.architectury_api_version,
"neoforgeversion": project.neoforge_version,
"neoforgeloaderversion": project.neoforge_loader_version,
"mcversion": project.minecraft_version,
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ pluginManagement {

include "common", "fabric", /*"forge",*/ "neoforge"

rootProject.name = 'FTB-Ultimine-1.20.6'
rootProject.name = 'FTB-Ultimine-1.21'
Loading