Skip to content

Commit

Permalink
fix: Fix more tags to be generated
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Sep 12, 2023
1 parent e4b998f commit 00a9ca2
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.blay09.mods.waystones.datagen;

import net.blay09.mods.waystones.block.ModBlocks;
import net.blay09.mods.waystones.tag.ModTags;
import net.blay09.mods.waystones.tag.ModBlockTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.core.HolderLookup;
Expand Down Expand Up @@ -31,7 +31,7 @@ protected void addTags(HolderLookup.Provider arg) {
mineableBuilder.add(scopedSharestone);
}

FabricTagProvider<Block>.FabricTagBuilder isTeleportTargetBuilder = getOrCreateTagBuilder(ModTags.IS_TELEPORT_TARGET);
FabricTagProvider<Block>.FabricTagBuilder isTeleportTargetBuilder = getOrCreateTagBuilder(ModBlockTags.IS_TELEPORT_TARGET);
isTeleportTargetBuilder.add(ModBlocks.waystone,
ModBlocks.sandyWaystone,
ModBlocks.mossyWaystone,
Expand All @@ -42,12 +42,14 @@ protected void addTags(HolderLookup.Provider arg) {
isTeleportTargetBuilder.add(scopedSharestone);
}

getOrCreateTagBuilder(ModTags.WAYSTONES).add(ModBlocks.waystone, ModBlocks.sandyWaystone, ModBlocks.mossyWaystone);
getOrCreateTagBuilder(ModBlockTags.WAYSTONES).add(ModBlocks.waystone, ModBlocks.sandyWaystone, ModBlocks.mossyWaystone);

FabricTagProvider<Block>.FabricTagBuilder sharestonesBuilder = getOrCreateTagBuilder(ModTags.SHARESTONES);
FabricTagProvider<Block>.FabricTagBuilder sharestonesBuilder = getOrCreateTagBuilder(ModBlockTags.SHARESTONES);
FabricTagProvider<Block>.FabricTagBuilder dyedSharestonesTag = getOrCreateTagBuilder(ModBlockTags.DYED_SHARESTONES);
sharestonesBuilder.add(ModBlocks.sharestone);
for (Block scopedSharestone : ModBlocks.scopedSharestones) {
sharestonesBuilder.add(scopedSharestone);
dyedSharestonesTag.add(scopedSharestone);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package net.blay09.mods.waystones.datagen;

import net.blay09.mods.waystones.block.ModBlocks;
import net.blay09.mods.waystones.item.ModItems;
import net.blay09.mods.waystones.tag.ModTags;
import net.blay09.mods.waystones.tag.ModItemTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;

import java.util.concurrent.CompletableFuture;

Expand All @@ -17,9 +19,17 @@ public WaystonesItemTagProvider(FabricDataOutput output, CompletableFuture<Holde

@Override
protected void addTags(HolderLookup.Provider lookup) {
getOrCreateTagBuilder(ModTags.WARP_SCROLLS).add(ModItems.warpScroll);
getOrCreateTagBuilder(ModTags.RETURN_SCROLLS).add(ModItems.returnScroll);
getOrCreateTagBuilder(ModTags.BOUND_SCROLLS).add(ModItems.boundScroll);
getOrCreateTagBuilder(ModTags.WARP_STONES).add(ModItems.warpStone);
getOrCreateTagBuilder(ModItemTags.WARP_SCROLLS).add(ModItems.warpScroll);
getOrCreateTagBuilder(ModItemTags.RETURN_SCROLLS).add(ModItems.returnScroll);
getOrCreateTagBuilder(ModItemTags.BOUND_SCROLLS).add(ModItems.boundScroll);
getOrCreateTagBuilder(ModItemTags.WARP_STONES).add(ModItems.warpStone);
getOrCreateTagBuilder(ModItemTags.WAYSTONES).add(ModBlocks.waystone.asItem(), ModBlocks.mossyWaystone.asItem(), ModBlocks.sandyWaystone.asItem());
FabricTagProvider<Item>.FabricTagBuilder sharestonesTag = getOrCreateTagBuilder(ModItemTags.SHARESTONES);
sharestonesTag.add(ModBlocks.sharestone.asItem());
FabricTagProvider<Item>.FabricTagBuilder dyedSharestonesTag = getOrCreateTagBuilder(ModItemTags.DYED_SHARESTONES);
for (Block scopedSharestone : ModBlocks.scopedSharestones) {
sharestonesTag.add(scopedSharestone.asItem());
dyedSharestonesTag.add(scopedSharestone.asItem());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"replace": false,
"values": [
"waystones:white_sharestone",
"waystones:orange_sharestone",
"waystones:magenta_sharestone",
"waystones:light_blue_sharestone",
"waystones:yellow_sharestone",
"waystones:lime_sharestone",
"waystones:pink_sharestone",
"waystones:gray_sharestone",
"waystones:light_gray_sharestone",
"waystones:cyan_sharestone",
"waystones:purple_sharestone",
"waystones:blue_sharestone",
"waystones:brown_sharestone",
"waystones:green_sharestone",
"waystones:red_sharestone",
"waystones:black_sharestone"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"replace": false,
"values": [
"waystones:white_sharestone",
"waystones:orange_sharestone",
"waystones:magenta_sharestone",
"waystones:light_blue_sharestone",
"waystones:yellow_sharestone",
"waystones:lime_sharestone",
"waystones:pink_sharestone",
"waystones:gray_sharestone",
"waystones:light_gray_sharestone",
"waystones:cyan_sharestone",
"waystones:purple_sharestone",
"waystones:blue_sharestone",
"waystones:brown_sharestone",
"waystones:green_sharestone",
"waystones:red_sharestone",
"waystones:black_sharestone"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"replace": false,
"values": [
"waystones:sharestone",
"waystones:white_sharestone",
"waystones:orange_sharestone",
"waystones:magenta_sharestone",
"waystones:light_blue_sharestone",
"waystones:yellow_sharestone",
"waystones:lime_sharestone",
"waystones:pink_sharestone",
"waystones:gray_sharestone",
"waystones:light_gray_sharestone",
"waystones:cyan_sharestone",
"waystones:purple_sharestone",
"waystones:blue_sharestone",
"waystones:brown_sharestone",
"waystones:green_sharestone",
"waystones:red_sharestone",
"waystones:black_sharestone"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"waystones:waystone",
"waystones:mossy_waystone",
"waystones:sandy_waystone"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.blay09.mods.waystones.config.WaystonesConfig;
import net.blay09.mods.waystones.core.PlayerWaystoneManager;
import net.blay09.mods.waystones.core.WaystoneSyncManager;
import net.blay09.mods.waystones.tag.ModTags;
import net.blay09.mods.waystones.tag.ModItemTags;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -73,7 +73,7 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {

@Override
protected InteractionResult handleActivation(Level world, BlockPos pos, Player player, WaystoneBlockEntityBase tileEntity, IWaystone waystone) {
if (player.getMainHandItem().is(ModTags.BOUND_SCROLLS)) {
if (player.getMainHandItem().is(ModItemTags.BOUND_SCROLLS)) {
return InteractionResult.PASS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.blay09.mods.waystones.config.InventoryButtonMode;
import net.blay09.mods.waystones.config.WaystonesConfig;
import net.blay09.mods.waystones.network.message.TeleportEffectMessage;
import net.blay09.mods.waystones.tag.ModTags;
import net.blay09.mods.waystones.tag.ModItemTags;
import net.blay09.mods.waystones.worldgen.namegen.NameGenerationMode;
import net.blay09.mods.waystones.worldgen.namegen.NameGenerator;
import net.minecraft.ChatFormatting;
Expand Down Expand Up @@ -328,10 +328,10 @@ private static boolean canDimensionalWarpBetween(Entity player, IWaystone waysto

public static ItemStack findWarpItem(Entity entity, WarpMode warpMode) {
return switch (warpMode) {
case WARP_SCROLL -> findWarpItem(entity, ModTags.WARP_SCROLLS);
case WARP_STONE -> findWarpItem(entity, ModTags.WARP_STONES);
case RETURN_SCROLL -> findWarpItem(entity, ModTags.RETURN_SCROLLS);
case BOUND_SCROLL -> findWarpItem(entity, ModTags.BOUND_SCROLLS);
case WARP_SCROLL -> findWarpItem(entity, ModItemTags.WARP_SCROLLS);
case WARP_STONE -> findWarpItem(entity, ModItemTags.WARP_STONES);
case RETURN_SCROLL -> findWarpItem(entity, ModItemTags.RETURN_SCROLLS);
case BOUND_SCROLL -> findWarpItem(entity, ModItemTags.BOUND_SCROLLS);
default -> ItemStack.EMPTY;
};
}
Expand Down Expand Up @@ -486,10 +486,10 @@ public static void deactivateWaystone(Player player, IWaystone waystone) {
private static boolean canUseWarpMode(Entity entity, WarpMode warpMode, ItemStack heldItem, @Nullable IWaystone fromWaystone) {
return switch (warpMode) {
case INVENTORY_BUTTON -> entity instanceof Player && PlayerWaystoneManager.canUseInventoryButton(((Player) entity));
case WARP_SCROLL -> !heldItem.isEmpty() && heldItem.is(ModTags.WARP_SCROLLS);
case BOUND_SCROLL -> !heldItem.isEmpty() && heldItem.is(ModTags.BOUND_SCROLLS);
case RETURN_SCROLL -> !heldItem.isEmpty() && heldItem.is(ModTags.RETURN_SCROLLS);
case WARP_STONE -> !heldItem.isEmpty() && heldItem.is(ModTags.WARP_STONES) && entity instanceof Player
case WARP_SCROLL -> !heldItem.isEmpty() && heldItem.is(ModItemTags.WARP_SCROLLS);
case BOUND_SCROLL -> !heldItem.isEmpty() && heldItem.is(ModItemTags.BOUND_SCROLLS);
case RETURN_SCROLL -> !heldItem.isEmpty() && heldItem.is(ModItemTags.RETURN_SCROLLS);
case WARP_STONE -> !heldItem.isEmpty() && heldItem.is(ModItemTags.WARP_STONES) && entity instanceof Player
&& PlayerWaystoneManager.canUseWarpStone(((Player) entity), heldItem);
case WAYSTONE_TO_WAYSTONE -> WaystonesConfig.getActive()
.restrictions.allowWaystoneToWaystoneTeleport && fromWaystone != null && fromWaystone.isValid()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.blay09.mods.waystones.api.TeleportDestination;
import net.blay09.mods.waystones.api.WaystoneOrigin;
import net.blay09.mods.waystones.block.WaystoneBlock;
import net.blay09.mods.waystones.tag.ModTags;
import net.blay09.mods.waystones.tag.ModBlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.Registries;
Expand Down Expand Up @@ -125,7 +125,7 @@ public ResourceLocation getWaystoneType() {
@Override
public boolean isValidInLevel(ServerLevel level) {
BlockState state = level.getBlockState(pos);
return state.is(ModTags.IS_TELEPORT_TARGET);
return state.is(ModBlockTags.IS_TELEPORT_TARGET);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.blay09.mods.waystones.tag;

import net.blay09.mods.waystones.Waystones;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;

public class ModBlockTags {
public static final TagKey<Block> IS_TELEPORT_TARGET = TagKey.create(Registries.BLOCK, new ResourceLocation(Waystones.MOD_ID, "is_teleport_target"));
public static final TagKey<Block> WAYSTONES = TagKey.create(Registries.BLOCK, new ResourceLocation(Waystones.MOD_ID, "waystones"));
public static final TagKey<Block> SHARESTONES = TagKey.create(Registries.BLOCK, new ResourceLocation(Waystones.MOD_ID, "sharestones"));
public static final TagKey<Block> DYED_SHARESTONES = TagKey.create(Registries.BLOCK, new ResourceLocation(Waystones.MOD_ID, "dyed_sharestones"));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package net.blay09.mods.waystones.tag;

import net.blay09.mods.waystones.Waystones;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;

public class ModItemTags {
public static final TagKey<Item> BOUND_SCROLLS = TagKey.create(Registries.ITEM, new ResourceLocation(Waystones.MOD_ID, "bound_scrolls"));
public static final TagKey<Item> RETURN_SCROLLS = TagKey.create(Registries.ITEM, new ResourceLocation(Waystones.MOD_ID, "return_scrolls"));
public static final TagKey<Item> WARP_SCROLLS = TagKey.create(Registries.ITEM, new ResourceLocation(Waystones.MOD_ID, "warp_scrolls"));
public static final TagKey<Item> WARP_STONES = TagKey.create(Registries.ITEM, new ResourceLocation(Waystones.MOD_ID, "warp_stones"));
public static final TagKey<Item> WAYSTONES = TagKey.create(Registries.ITEM, new ResourceLocation(Waystones.MOD_ID, "waystones"));
public static final TagKey<Item> SHARESTONES = TagKey.create(Registries.ITEM, new ResourceLocation(Waystones.MOD_ID, "sharestones"));
public static final TagKey<Item> DYED_SHARESTONES = TagKey.create(Registries.ITEM, new ResourceLocation(Waystones.MOD_ID, "dyed_sharestones"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;

@Deprecated
public class ModTags {

public static final TagKey<Item> BOUND_SCROLLS = TagKey.create(Registries.ITEM, new ResourceLocation(Waystones.MOD_ID, "bound_scrolls"));
Expand Down

0 comments on commit 00a9ca2

Please sign in to comment.