Skip to content

Commit

Permalink
Rename to TagRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
WenXin20 committed Sep 6, 2024
1 parent 47c5a2f commit ab33d8c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.wenxin2.marioverse.blocks.entities.WarpPipeBlockEntity;
import com.wenxin2.marioverse.init.BlockRegistry;
import com.wenxin2.marioverse.init.ConfigRegistry;
import com.wenxin2.marioverse.init.ModTags;
import com.wenxin2.marioverse.init.TagRegistry;
import com.wenxin2.marioverse.items.LinkerItem;
import java.util.Collection;
import java.util.Map;
Expand Down Expand Up @@ -416,14 +416,14 @@ public void entityInside(BlockState state, Level world, BlockPos pos, Entity ent
int blockY = pos.getY();
int blockZ = pos.getZ();

if (!entity.isShiftKeyDown() && ConfigRegistry.ALLOW_FAST_TRAVEL.get() && !entity.getType().is(ModTags.QUICK_TRAVEL_BLACKLIST))
if (!entity.isShiftKeyDown() && ConfigRegistry.ALLOW_FAST_TRAVEL.get() && !entity.getType().is(TagRegistry.QUICK_TRAVEL_BLACKLIST))
entity.setSwimming(true);

if ((entityY < blockY + 0.98 && entityY > blockY + 0.02)
&& (entityX < blockX + 0.98 && entityX > blockX + 0.02)
&& (entityZ < blockZ + 0.98 && entityZ > blockZ + 0.02)
&& !entity.isShiftKeyDown() && ConfigRegistry.ALLOW_FAST_TRAVEL.get()
&& !entity.getType().is(ModTags.QUICK_TRAVEL_BLACKLIST)) {
&& !entity.getType().is(TagRegistry.QUICK_TRAVEL_BLACKLIST)) {
this.moveEntityInPipe(entity);

if (!world.isClientSide) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.wenxin2.marioverse.blocks.entities.QuestionBlockEntity;
import com.wenxin2.marioverse.init.ConfigRegistry;
import com.wenxin2.marioverse.init.ModTags;
import com.wenxin2.marioverse.init.TagRegistry;
import com.wenxin2.marioverse.init.SoundRegistry;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -113,7 +113,7 @@ public void spawnEntity(Level world, Entity entity, BlockPos pos, ItemStack stac
if (stack.getItem() instanceof SpawnEggItem spawnEgg && ConfigRegistry.QUESTION_SPAWNS_MOBS.get()) {
EntityType<?> entityType = spawnEgg.getType(stack);

if (world instanceof ServerLevel serverWorld && !entityType.is(ModTags.QUESTION_BLOCK_BLACKLIST)) { // Check this
if (world instanceof ServerLevel serverWorld && !entityType.is(TagRegistry.QUESTION_BLOCK_BLACKLIST)) { // Check this
if (world.getBlockState(pos.above()).isAir())
entityType.spawn(serverWorld, stack, null, pos.above(2), MobSpawnType.SPAWN_EGG, true, true);
else entityType.spawn(serverWorld, stack, null, pos.below((int) entityType.getHeight()), MobSpawnType.SPAWN_EGG, true, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void loadAdditional(CompoundTag tag, HolderLookup.Provider provider) {
public void addItem(ItemStack stack) {
ItemStack existingStack = items.getStackInSlot(0);
if (existingStack.isEmpty()) {
items.setStackInSlot(0, stack);
items.setStackInSlot(0, stack.split(stack.getMaxStackSize()));
} else if (ItemStack.isSameItemSameComponents(existingStack, stack)) {
int countToAdd = Math.min(stack.getMaxStackSize() - existingStack.getCount(), stack.getCount());
existingStack.grow(countToAdd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;

public class ModTags {
public class TagRegistry {
public static final TagKey<Block> DYEABLE_WARP_PIPE_BLOCKS = blockTags(Marioverse.MOD_ID, "dyeable_marioverse");
public static final TagKey<Block> WARP_PIPE_BLOCKS = blockTags(Marioverse.MOD_ID, "marioverse");
public static final TagKey<Block> WRENCH_EFFICIENT = blockTags(Marioverse.MOD_ID, "wrench_efficient");
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/com/wenxin2/marioverse/items/WrenchItem.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.wenxin2.marioverse.items;

import com.wenxin2.marioverse.init.ModTags;
import com.wenxin2.marioverse.init.TagRegistry;
import java.util.List;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
import net.minecraft.core.component.DataComponents;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.EquipmentSlotGroup;
import net.minecraft.world.entity.LivingEntity;
Expand All @@ -21,9 +19,7 @@
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.component.ItemAttributeModifiers;
import net.minecraft.world.item.component.Tool;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.common.Tags;

Expand Down Expand Up @@ -77,7 +73,7 @@ public boolean canAttackBlock(BlockState state, Level world, BlockPos pos, Playe
}

public static Tool createToolProperties() {
return new Tool(List.of(Tool.Rule.overrideSpeed(ModTags.WRENCH_EFFICIENT, 1.5F)), 1.0F, 2);
return new Tool(List.of(Tool.Rule.overrideSpeed(TagRegistry.WRENCH_EFFICIENT, 1.5F)), 1.0F, 2);
}

public static ItemAttributeModifiers createAttributes(Tier tier, int attackDamage, float attackSpeed) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/wenxin2/marioverse/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.wenxin2.marioverse.blocks.WarpPipeBlock;
import com.wenxin2.marioverse.blocks.entities.WarpPipeBlockEntity;
import com.wenxin2.marioverse.init.ConfigRegistry;
import com.wenxin2.marioverse.init.ModTags;
import com.wenxin2.marioverse.init.TagRegistry;
import java.util.Collection;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -136,7 +136,7 @@ public void baseTick(CallbackInfo ci) {
int blockZ = pos.getZ();

if (!stateAboveEntity.getValue(WarpPipeBlock.CLOSED) && blockEntity instanceof WarpPipeBlockEntity warpPipeBE && warpPipeBE.getLevel() != null
&& !warpPipeBE.preventWarp && ConfigRegistry.TELEPORT_PLAYERS.get() && !this.getType().is(ModTags.WARP_BLACKLIST)) {
&& !warpPipeBE.preventWarp && ConfigRegistry.TELEPORT_PLAYERS.get() && !this.getType().is(TagRegistry.WARP_BLACKLIST)) {
warpPos = warpPipeBE.destinationPos;
int entityId = this.getId();

Expand Down Expand Up @@ -176,7 +176,7 @@ else if (warpPipeBE.getUuid() != null && warpPipeBE.getWarpUuid() != null && War
int blockZ = pos.getZ();

if (!state.getValue(WarpPipeBlock.CLOSED) && blockEntity instanceof WarpPipeBlockEntity warpPipeBE
&& !warpPipeBE.preventWarp && ConfigRegistry.TELEPORT_NON_MOBS.get() && !this.getType().is(ModTags.WARP_BLACKLIST)) {
&& !warpPipeBE.preventWarp && ConfigRegistry.TELEPORT_NON_MOBS.get() && !this.getType().is(TagRegistry.WARP_BLACKLIST)) {
warpPos = warpPipeBE.destinationPos;
int entityId = this.getId();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.wenxin2.marioverse.blocks.WarpPipeBlock;
import com.wenxin2.marioverse.blocks.entities.WarpPipeBlockEntity;
import com.wenxin2.marioverse.init.ConfigRegistry;
import com.wenxin2.marioverse.init.ModTags;
import com.wenxin2.marioverse.init.TagRegistry;
import java.util.Collection;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -127,7 +127,7 @@ public void baseTick(CallbackInfo ci) {
int blockZ = pos.getZ();

if (!stateAboveEntity.getValue(WarpPipeBlock.CLOSED) && blockEntity instanceof WarpPipeBlockEntity warpPipeBE && warpPipeBE.getLevel() != null
&& !warpPipeBE.preventWarp && this.getType() != EntityType.PLAYER && ConfigRegistry.TELEPORT_PLAYERS.get() && !this.getType().is(ModTags.WARP_BLACKLIST)
&& !warpPipeBE.preventWarp && this.getType() != EntityType.PLAYER && ConfigRegistry.TELEPORT_PLAYERS.get() && !this.getType().is(TagRegistry.WARP_BLACKLIST)
&& !this.getPersistentData().getBoolean("marioverse:prevent_warp")) {
warpPos = warpPipeBE.destinationPos;
int entityId = this.getId();
Expand Down Expand Up @@ -168,7 +168,7 @@ else if (warpPipeBE.getUuid() != null && warpPipeBE.getWarpUuid() != null && War
int blockZ = pos.getZ();

if (!state.getValue(WarpPipeBlock.CLOSED) && blockEntity instanceof WarpPipeBlockEntity warpPipeBE && this.getType() != EntityType.PLAYER
&& !warpPipeBE.preventWarp && ConfigRegistry.TELEPORT_MOBS.get() && !this.getType().is(ModTags.WARP_BLACKLIST)
&& !warpPipeBE.preventWarp && ConfigRegistry.TELEPORT_MOBS.get() && !this.getType().is(TagRegistry.WARP_BLACKLIST)
&& !this.getPersistentData().getBoolean("marioverse:prevent_warp")) {
warpPos = warpPipeBE.destinationPos;
int entityId = this.getId();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/wenxin2/marioverse/mixin/PlayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.wenxin2.marioverse.blocks.entities.QuestionBlockEntity;
import com.wenxin2.marioverse.blocks.entities.WarpPipeBlockEntity;
import com.wenxin2.marioverse.init.ConfigRegistry;
import com.wenxin2.marioverse.init.ModTags;
import com.wenxin2.marioverse.init.TagRegistry;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -140,7 +140,7 @@ public void baseTick() {
int blockZ = pos.getZ();

if (!stateAboveEntity.getValue(WarpPipeBlock.CLOSED) && blockEntity instanceof WarpPipeBlockEntity warpPipeBE && warpPipeBE.getLevel() != null
&& !warpPipeBE.preventWarp && ConfigRegistry.TELEPORT_PLAYERS.get() && !this.getType().is(ModTags.WARP_BLACKLIST)
&& !warpPipeBE.preventWarp && ConfigRegistry.TELEPORT_PLAYERS.get() && !this.getType().is(TagRegistry.WARP_BLACKLIST)
&& !this.getPersistentData().getBoolean("marioverse:prevent_warp")) {
warpPos = warpPipeBE.destinationPos;
int entityId = this.getId();
Expand Down Expand Up @@ -183,7 +183,7 @@ else if (warpPipeBE.getUuid() != null && warpPipeBE.getWarpUuid() != null && War
int blockZ = pos.getZ();

if (!state.getValue(WarpPipeBlock.CLOSED) && blockEntity instanceof WarpPipeBlockEntity warpPipeBE && warpPipeBE.getLevel() != null
&& !warpPipeBE.preventWarp && ConfigRegistry.TELEPORT_PLAYERS.get() && !this.getType().is(ModTags.WARP_BLACKLIST)
&& !warpPipeBE.preventWarp && ConfigRegistry.TELEPORT_PLAYERS.get() && !this.getType().is(TagRegistry.WARP_BLACKLIST)
&& !this.getPersistentData().getBoolean("marioverse:prevent_warp")) {
// WarpData warpData = WarpProxy.getInstance().getWarp(warpPipeBE.warpUuid);
warpPos = warpPipeBE.destinationPos;
Expand Down Expand Up @@ -251,7 +251,7 @@ else if (warpPipeBE.getUuid() != null && warpPipeBE.getWarpUuid() != null && War
} /* else if (this.getWarpCooldown() <= 10)
displayDestinationMissingMessage(); */ else if (warpPipeBE.hasDestinationPos()) this.marioverse$displayCooldownMessage();
}
} else if (!state.getValue(WarpPipeBlock.CLOSED) && (!ConfigRegistry.TELEPORT_PLAYERS.get() || this.getType().is(ModTags.WARP_BLACKLIST))) {
} else if (!state.getValue(WarpPipeBlock.CLOSED) && (!ConfigRegistry.TELEPORT_PLAYERS.get() || this.getType().is(TagRegistry.WARP_BLACKLIST))) {
if (state.getValue(WarpPipeBlock.FACING) == Direction.UP && this.isShiftKeyDown() && (entityY + this.getBbHeight() >= blockY - 1)
&& (entityX < blockX + 1 && entityX > blockX) && (entityZ < blockZ + 1 && entityZ > blockZ)) {
this.marioverse$displayNoTeleportMessage();
Expand Down Expand Up @@ -296,7 +296,7 @@ else if (warpPipeBE.getUuid() != null && warpPipeBE.getWarpUuid() != null && War

@Unique
public void marioverse$displayNoTeleportMessage() {
if (!ConfigRegistry.TELEPORT_PLAYERS.get() || this.getType().is(ModTags.WARP_BLACKLIST)) {
if (!ConfigRegistry.TELEPORT_PLAYERS.get() || this.getType().is(TagRegistry.WARP_BLACKLIST)) {
this.displayClientMessage(Component.translatable("display.marioverse.players_cannot_teleport")
.withStyle(ChatFormatting.RED), true);
}
Expand Down

0 comments on commit ab33d8c

Please sign in to comment.