Skip to content

Commit

Permalink
Merge branch 'master' into 1.21.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
  • Loading branch information
Treetrain1 committed Dec 26, 2024
2 parents a286290 + 9df20eb commit fd97d9f
Show file tree
Hide file tree
Showing 19 changed files with 405 additions and 115 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ Make sure to clear this after each release
Put changelog here:

-----------------
- Fixed a crash with VMP.
- Fixed custom Grass Color Modifiers to work 100% of the time.
- Added `PlaceInAirBlockItem,` thanks to Qzimyion!
- Updated to Kotlin 2.1
- Added `ShapelessRecipeBuilderExtension`
32 changes: 10 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ plugins {
id("org.ajoberstar.grgit") version("+")
id("org.quiltmc.gradle.licenser") version("+")
id("com.modrinth.minotaur") version("+")
id("com.github.johnrengelman.shadow") version("+")
id("com.gradleup.shadow") version("+")
`maven-publish`
eclipse
idea
`java-library`
java
kotlin("jvm") version("2.0.21")
kotlin("jvm") version("2.1.0")
}

val minecraft_version: String by project
Expand Down Expand Up @@ -190,42 +190,30 @@ 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.
maven {
url = uri("https://jitpack.io")
}
maven {
maven("https://api.modrinth.com/maven") {
name = "Modrinth"
url = uri("https://api.modrinth.com/maven")

content {
includeGroup("maven.modrinth")
}
}
maven {
url = uri("https://maven.terraformersmc.com")

maven("https://maven.terraformersmc.com") {
content {
includeGroup("com.terraformersmc")
}
}
maven {
setUrl("https://maven.shedaniel.me/")
}
maven {
setUrl("https://maven.minecraftforge.net")
}
maven {
setUrl("https://maven.parchmentmc.org")
}
maven {
maven("https://maven.shedaniel.me/")
maven("https://maven.minecraftforge.net")
maven("https://maven.parchmentmc.org")
maven("https://maven.quiltmc.org/repository/release") {
name = "Quilt"
setUrl("https://maven.quiltmc.org/repository/release")
}

flatDir {
dirs("libs")
}
mavenCentral()
maven("https://jitpack.io")
}

dependencies {
Expand Down Expand Up @@ -309,7 +297,7 @@ tasks {

shadowJar {
configurations = listOf(relocModApi)
isEnableRelocation = true
enableRelocation = true
relocationPrefix = "net.frozenblock.lib.shadow"
dependencies {
exclude {
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

# Dependencies
fabric_api_version=0.110.0+1.21.3
fabric_kotlin_version=1.12.3+kotlin.2.0.21
fabric_kotlin_version=1.13.0+kotlin.2.1.0
toml4j_version=0.7.2
jankson_version=1.2.3
xjs_data_version=0.6
xjs_compat_version=0.8
fresult_version=3.1

# External Mods
modmenu_version=11.0.0-beta.1
cloth_config_version=14.0.126
terrablender_version=1.20.2-3.2.0.14
modmenu_version=11.0.3
cloth_config_version=15.0.140
terrablender_version=1.21.1-4.1.0.3
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2024 FrozenBlock
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package net.frozenblock.lib.item.api;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.ProjectileUtil;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;

public class PlaceInAirBlockItem extends BlockItem {

public PlaceInAirBlockItem(Block block, Item.Properties properties) {
super(block, properties);
}

@Override
@NotNull
public InteractionResultHolder<ItemStack> use(@NotNull Level level, @NotNull Player player, InteractionHand hand) {
ItemStack itemStack = player.getItemInHand(hand);

double blockInteractionRange = player.blockInteractionRange();

Vec3 lookAngle = player.getLookAngle();
Vec3 playerPos = player.getEyePosition();
Vec3 placementPos = playerPos.add(
lookAngle.scale(blockInteractionRange)
);

AABB entityPickBox = player.getBoundingBox().expandTowards(lookAngle.scale(blockInteractionRange)).inflate(1D, 1D, 1D);
EntityHitResult entityHitResult = ProjectileUtil.getEntityHitResult(
player,
playerPos,
placementPos,
entityPickBox,
entityx -> !entityx.isSpectator() && entityx.isPickable(),
Mth.square(blockInteractionRange)
);

if (entityHitResult == null) {
BlockPos pos = BlockPos.containing(placementPos);

if (level.isInWorldBounds(pos) && level.getWorldBorder().isWithinBounds(pos) && level.getBlockState(pos).canBeReplaced()) {
Direction reflectedFacingDirection = Direction.getNearest(lookAngle);
BlockPlaceContext context = new BlockPlaceContext(player, hand, itemStack, new BlockHitResult(pos.getCenter(), reflectedFacingDirection, pos, false));
InteractionResult result = this.useOn(context);
if (result.consumesAction()) {
return InteractionResultHolder.sidedSuccess(itemStack, !level.isClientSide());
}
}
}
return super.use(level, player, hand);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright (C) 2024 FrozenBlock
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package net.frozenblock.lib.item.mixin.client;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.frozenblock.lib.item.api.PlaceInAirBlockItem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

@Environment(EnvType.CLIENT)
@Mixin(LevelRenderer.class)
public abstract class LevelRendererMixin {

@Shadow
@Final
private Minecraft minecraft;

@ModifyExpressionValue(
method = "renderLevel",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/phys/HitResult;getType()Lnet/minecraft/world/phys/HitResult$Type;"
)
)
public HitResult.Type frozenLib$useBlockTypeIfPlaceableInAir(
HitResult.Type original,
@Share("frozenLib$canPlaceInAir") LocalBooleanRef canPlaceInAir
) {
if (this.minecraft.player != null && original == HitResult.Type.MISS) {
if (this.minecraft.player.getMainHandItem().getItem() instanceof PlaceInAirBlockItem || this.minecraft.player.getOffhandItem().getItem() instanceof PlaceInAirBlockItem) {
canPlaceInAir.set(true);
return HitResult.Type.BLOCK;
}
}

canPlaceInAir.set(false);
return original;
}

@ModifyExpressionValue(
method = "renderLevel",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/block/state/BlockState;isAir()Z"
)
)
public boolean frozenLib$overrideAirCheck(
boolean original,
@Share("frozenLib$canPlaceInAir") LocalBooleanRef canPlaceInAir
) {
return original && !canPlaceInAir.get();
}

@WrapOperation(
method = "renderHitOutline",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/LevelRenderer;renderShape(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraft/world/phys/shapes/VoxelShape;DDDFFFF)V"
)
)
private void frozenLib$renderOutlineForAir(
PoseStack poseStack, VertexConsumer vertexConsumer, VoxelShape voxelShape, double d, double e, double f, float g, float h, float i, float j, Operation<Void> original,
@Local(argsOnly = true) BlockState blockState
) {
if (blockState.isAir()) voxelShape = Shapes.block();

original.call(poseStack, vertexConsumer, voxelShape, d, e, f, g, h, i, j);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@
import org.jetbrains.annotations.Nullable;

public interface ShapedRecipeBuilderExtension {

ShapedRecipeBuilder frozenLib$patch(@Nullable DataComponentPatch tag);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2024 FrozenBlock
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package net.frozenblock.lib.recipe.api;

import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
import org.jetbrains.annotations.Nullable;

public interface ShapelessRecipeBuilderExtension {
ShapelessRecipeBuilder frozenLib$patch(@Nullable DataComponentPatch tag);
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,4 @@ private void modifySave(RecipeOutput instance, ResourceKey<Recipe<?>> recipeId,
((ShapedRecipeBuilderExtension) recipe).frozenLib$patch(this.patch);
operation.call(instance, recipeId, recipe, holder);
}

/*@Mixin(ShapedRecipeBuilder.Result.class)
private static class ResultMixin implements ShapedRecipeBuilderExtension {
@Unique
@Nullable
private CompoundTag tag;
@Override
public ShapedRecipeBuilder frozenLib$tag(CompoundTag tag) {
this.tag = tag;
return null;
}
@Override
public @Nullable CompoundTag frozenLib$getTag() {
return this.tag;
}
@Inject(method = "serializeRecipeData", at = @At(value = "INVOKE", target = "Lcom/google/gson/JsonObject;add(Ljava/lang/String;Lcom/google/gson/JsonElement;)V", ordinal = 3), locals = LocalCapture.CAPTURE_FAILHARD)
private void addTagData(JsonObject json, CallbackInfo ci, JsonArray jsonArray, JsonObject jsonObject, JsonObject jsonObject2) {
if (this.tag != null) {
jsonObject2.add("tag", CompoundTag.CODEC.encodeStart(JsonOps.INSTANCE, this.tag).getOrThrow(false, str -> {}));
}
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public class ShapedRecipeMixin implements ShapedRecipeBuilderExtension {

@Override
public ShapedRecipeBuilder frozenLib$patch(@Nullable DataComponentPatch patch) {
if (patch != null)
this.result.applyComponents(patch);
if (patch != null) this.result.applyComponents(patch);
return null;
}
}
Loading

0 comments on commit fd97d9f

Please sign in to comment.