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
33 changes: 33 additions & 0 deletions src/main/java/astro/tjm/TheJourneyMatters.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
import net.minecraft.resources.Identifier;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.animal.wolf.Wolf;
import net.minecraft.world.level.block.Blocks;

import java.util.List;

/**
* Main entrypoint. Registers the listeners that award the code-driven Journey advancements.
*/
Expand Down Expand Up @@ -45,6 +52,32 @@ public void onInitialize() {

award(owner, world, "first_of_its_kind", "wolf_killed");
});


ServerTickEvents.END_LEVEL_TICK.register(server -> {
List<ServerPlayer> players = server.players();
for (ServerPlayer player : players) {
Inventory inventory = player.getInventory();
for (int slot = 0; slot < inventory.getContainerSize(); slot++) {
ItemStack stack = inventory.getItem(slot);
if (stack.getItem() == Items.ELYTRA) {
ItemStack extractedStack = inventory.removeItem(slot, stack.getCount());
player.drop(extractedStack, false, null);
}
}
}
});

ServerTickEvents.END_LEVEL_TICK.register(server -> {
List<ServerPlayer> players = server.players();
for (ServerPlayer player : players) {
ItemStack chest = player.getItemBySlot(EquipmentSlot.CHEST);
if (chest.getItem().equals(Items.ELYTRA)) {
player.setItemSlot(EquipmentSlot.CHEST, ItemStack.EMPTY);
player.drop(new ItemStack(Items.ELYTRA), false, null);
}
}
});
Comment on lines +70 to +80
}

private static void award(ServerPlayer player, ServerLevel world, String advancementPath, String criterion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@


@Mixin(BlockItem.class)
/**
* Cancels block placement in the Nether above the configured height or for disallowed blocks.
*/
public class TJMMixin {
public class BlockItemMixin {
@Inject(at = @At("HEAD"), method = "place", cancellable = true)
private void tjm$preventIceInNether(
BlockPlaceContext placeContext,
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/overworldinfrastructure.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"package": "astro.tjm.mixin",
"compatibilityLevel": "JAVA_25",
"mixins": [
"TJMMixin"
"BlockItemMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down
Loading