Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v2
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'maven-publish'
}

Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.3
fabric_version=0.102.1+1.21.1
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.8
loader_version=0.16.10
fabric_version=0.118.5+1.21.4

# Mod Properties
mod_version = 2.0.0-beta-1
mod_version = 2.0.0
maven_group = ru.nern
archives_base_name = not-so-shadow-extras-1.21
archives_base_name = not-so-shadow-extras-1.21.4
fconfig_version=085f7c7

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
28 changes: 14 additions & 14 deletions src/main/java/ru/nern/notsoshadowextras/NSSECommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.Registries;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
Expand All @@ -31,6 +30,7 @@
import java.util.Optional;

import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.server.command.CommandManager.argument;

public class NSSECommands {
private static final SimpleCommandExceptionType IS_NOT_A_BLOCK = new SimpleCommandExceptionType(new LiteralMessage("Selected item is not a block"));
Expand All @@ -39,26 +39,23 @@ public class NSSECommands {
private static final SuggestionProvider<ServerCommandSource> BLOCK_ENTITIES = (context, builder) -> CommandSource.suggestIdentifiers(Registries.BLOCK_ENTITY_TYPE.getIds(), builder);

protected static void init() {
if(FabricLoader.getInstance().isModLoaded("fabric-command-api-v2") && NSSE.config().Additions.BlockEntitySwapCommand) {
if (FabricLoader.getInstance().isModLoaded("fabric-command-api-v2") && NSSE.config().Additions.BlockEntitySwapCommand) {
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(literal("nsse")
.requires(source -> source.hasPermissionLevel(3))
.then(literal("exists")
.then(CommandManager.argument( "pos", BlockPosArgumentType.blockPos())
.executes(ctx -> blockEntityExists(ctx.getSource(), BlockPosArgumentType.getLoadedBlockPos(ctx, "pos")))))
.then(argument("pos", BlockPosArgumentType.blockPos())
.executes(ctx -> blockEntityExists(ctx.getSource(), BlockPosArgumentType.getLoadedBlockPos(ctx, "pos")))))
.then(literal("swap")
.then(CommandManager.literal("block")
.then(CommandManager.argument("pos", BlockPosArgumentType.blockPos())
.then(literal("set")
.then(CommandManager.argument("blockEntity", IdentifierArgumentType.identifier()).suggests(BLOCK_ENTITIES)
.executes(ctx -> swapAtPos(ctx.getSource(), IdentifierArgumentType.getIdentifier(ctx, "blockEntity"), BlockPosArgumentType.getLoadedBlockPos(ctx, "pos")))))))
.then(CommandManager.argument("blockEntity", IdentifierArgumentType.identifier()).suggests(BLOCK_ENTITIES)
.executes(ctx -> swap(ctx.getSource(), IdentifierArgumentType.getIdentifier(ctx, "blockEntity")))))));
.then(argument("blockEntity", IdentifierArgumentType.identifier()).suggests(BLOCK_ENTITIES)
.executes(ctx -> swap(ctx.getSource(), IdentifierArgumentType.getIdentifier(ctx, "blockEntity")))
.then(argument("pos", BlockPosArgumentType.blockPos())
.executes(ctx -> swapAtPos(ctx.getSource(), IdentifierArgumentType.getIdentifier(ctx, "blockEntity"), BlockPosArgumentType.getLoadedBlockPos(ctx, "pos"))))))));
}
}

public static int blockEntityExists(ServerCommandSource source, BlockPos pos) {
BlockEntity blockEntity = source.getWorld().getChunk(pos).blockEntities.get(pos);
;

if(blockEntity == null) {
source.sendFeedback(() ->
Text.literal("Block entity does not exist at this position"), false);
Expand All @@ -71,6 +68,9 @@ public static int blockEntityExists(ServerCommandSource source, BlockPos pos) {
}

public static int swapAtPos(ServerCommandSource source, Identifier id, BlockPos pos) throws CommandSyntaxException {
if (!(source.getWorld().getBlockState(pos).getBlock() instanceof BlockWithEntity)) {
throw BLOCK_ENTITY_UNSUPPORTED.create();
}
swapAtPos(source.getWorld(), id, pos);
source.sendFeedback(() ->
Text.literal(String.format("The block entity at position %s has been changed to %s", pos.toShortString(), id.toString())), false);
Expand All @@ -80,7 +80,7 @@ public static int swapAtPos(ServerCommandSource source, Identifier id, BlockPos
public static void swapAtPos(ServerWorld world, Identifier id, BlockPos pos) throws CommandSyntaxException {
BlockEntity current = world.getBlockEntity(pos);

Optional<BlockEntity> blockEntity = Registries.BLOCK_ENTITY_TYPE.getOrEmpty(id).map(type -> {
Optional<BlockEntity> blockEntity = Registries.BLOCK_ENTITY_TYPE.getOptionalValue(id).map(type -> {
try {
return type.instantiate(pos, world.getBlockState(pos));
} catch (Throwable throwable) {
Expand All @@ -107,7 +107,7 @@ public static int swap(ServerCommandSource source, Identifier blockEntity) throw
stack.set(DataComponentTypes.LORE, new LoreComponent(Collections.singletonList(Text.literal("§f+"+ blockEntity).formatted(Formatting.WHITE))));

source.sendFeedback(() ->
Text.literal(String.format("%s now has %s", stack.getItem().getName(), blockEntity)), false);
Text.literal(String.format("%s now has %s", Registries.ITEM.getId(stack.getItem()) , blockEntity)), false);
return 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class BlockItemMixin {

BlockPos pos = context.getBlockPos();

Optional<BlockEntity> blockEntity = Registries.BLOCK_ENTITY_TYPE.getOrEmpty(identifier).map(type -> {
Optional<BlockEntity> blockEntity = Registries.BLOCK_ENTITY_TYPE.getOptionalValue(identifier).map(type -> {
try {
return type.instantiate(context.getBlockPos(), context.getWorld().getBlockState(pos));
} catch (Throwable throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@
import net.minecraft.item.BoatItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.nern.notsoshadowextras.NSSE;

@Mixin(BoatItem.class)
public class BoatItemMixin {
@Inject(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z"))
private void notsoshadowextras$decrement(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> cir, @Local HitResult result) {
private void notsoshadowextras$decrement(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<ActionResult.Success> cir, @Local HitResult result) {
user.getStackInHand(hand).decrementUnlessCreative(1, user);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import ru.nern.notsoshadowextras.NSSE;

@Mixin(ServerCrashSafePacketListener.class)
public interface ServerCrashSafePLMixin_HideST {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.nern.notsoshadowextras.NSSE;

@Mixin(FlintAndSteelItem.class)
public class FlintAndSteelItemMixin {
Expand Down Expand Up @@ -48,6 +47,6 @@ public class FlintAndSteelItemMixin {
@Inject(method = "useOnBlock", at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/World;emitGameEvent(Lnet/minecraft/entity/Entity;Lnet/minecraft/registry/entry/RegistryEntry;Lnet/minecraft/util/math/BlockPos;)V", ordinal = 1, shift = At.Shift.AFTER), cancellable = true)
private void notsoshadowextras$cancelFlintAndSteelDamage(ItemUsageContext context, CallbackInfoReturnable<ActionResult> cir) {
cir.setReturnValue(ActionResult.success(context.getWorld().isClient()));
cir.setReturnValue(ActionResult.SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.nern.notsoshadowextras.NSSE;

@Mixin(PumpkinBlock.class)
public class PumpkinBlockMixin {
@Inject(method = "onUseWithItem", at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z", ordinal = 0))
private void notsoshadowextras$damageShears(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ItemActionResult> cir) {
private void notsoshadowextras$damageShears(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
player.getStackInHand(hand).damage(1, player, LivingEntity.getSlotForHand(hand));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.nern.notsoshadowextras.NSSE;

@Mixin(TntBlock.class)
public class TntBlockMixin {
@Inject(method = "onUseWithItem", at = @At(value = "INVOKE",
target = "Lnet/minecraft/entity/player/PlayerEntity;incrementStat(Lnet/minecraft/stat/Stat;)V", ordinal = 0, shift = At.Shift.AFTER))
private void notsoshadowextras$removeTNTBlock(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ItemActionResult> cir) {
private void notsoshadowextras$removeTNTBlock(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), Block.NOTIFY_ALL | Block.REDRAW_ON_MAIN_THREAD);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.nern.notsoshadowextras.NSSE;

@Mixin(FlowerPotBlock.class)
public class FlowerPotBlockMixin {

@Inject(method = "onUseWithItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private void notsoshadowextras$decrement(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ItemActionResult> cir) {
private void notsoshadowextras$decrement(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
stack.decrementUnlessCreative(1, player);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
],

"depends": {
"fabricloader": ">=0.15.0",
"minecraft": ">1.20.4",
"fabricloader": ">=0.16.0",
"minecraft": "1.21.4",
"java": ">=17"
},
"suggests": {
"another-mod": "*"
"recommends": {
"antishadowpatch": ">=2.0.0"
},
"accessWidener": "notsoshadowextras.accesswidener"
}