Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加无磁性tag #1492

Merged
merged 2 commits into from
Jan 14, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"anvilcraft:spectral_anvil"
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"values": [
"anvilcraft:giant_anvil",
"anvilcraft:transmission_pole",
"anvilcraft:remote_transmission_pole",
"anvilcraft:tesla_tower",
"anvilcraft:overseer",
"anvilcraft:giant_anvil",
"anvilcraft:transmission_pole",
"anvilcraft:remote_transmission_pole",
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/dev/dubhe/anvilcraft/block/MagnetBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable;
import dev.dubhe.anvilcraft.entity.AnimateAscendingBlockEntity;

import dev.dubhe.anvilcraft.init.ModBlocks;
import dev.dubhe.anvilcraft.init.ModBlockTags;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
Expand Down Expand Up @@ -63,7 +63,6 @@ protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockSt
}

@Override

public void neighborChanged(
BlockState state,
Level level,
Expand Down Expand Up @@ -97,7 +96,7 @@ private void attract(BlockState state, Level level, BlockPos magnetPos) {
currentPos = currentPos.below();
BlockState state1 = level.getBlockState(currentPos);

if (state1.is(BlockTags.ANVIL) && !state1.is(ModBlocks.SPECTRAL_ANVIL)) {
if (state1.is(BlockTags.ANVIL) && !state1.is(ModBlockTags.NON_MAGNETIC)) {
level.destroyBlock(magnetPos.below(), true);
level.setBlockAndUpdate(magnetPos.below(), state1);
level.setBlockAndUpdate(currentPos, Blocks.AIR.defaultBlockState());
Expand All @@ -109,7 +108,7 @@ private void attract(BlockState state, Level level, BlockPos magnetPos) {
level.getEntitiesOfClass(FallingBlockEntity.class, new AABB(currentPos));
for (FallingBlockEntity entity : entities) {
BlockState state2 = entity.getBlockState();
if (state2.is(BlockTags.ANVIL) && !state2.is(ModBlocks.SPECTRAL_ANVIL)) {
if (state2.is(BlockTags.ANVIL) && !state2.is(ModBlockTags.NON_MAGNETIC)) {
level.destroyBlock(magnetPos.below(), true);
level.setBlockAndUpdate(magnetPos.below(), state2);
entity.remove(Entity.RemovalReason.DISCARDED);
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/dev/dubhe/anvilcraft/data/tags/BlockTagLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,17 @@ public static void init(@NotNull RegistrateTagsProvider<Block> provider) {

//mekanism integration
provider.addTag(ModBlockTags.MEKANISM_CARDBOARD_BOX_BLACKLIST)
.add(ModBlocks.GIANT_ANVIL.getKey())
.add(ModBlocks.TRANSMISSION_POLE.getKey())
.add(ModBlocks.REMOTE_TRANSMISSION_POLE.getKey())
.add(ModBlocks.TESLA_TOWER.getKey())
.add(ModBlocks.OVERSEER_BLOCK.getKey());
.add(ModBlocks.GIANT_ANVIL.getKey())
.add(ModBlocks.TRANSMISSION_POLE.getKey())
.add(ModBlocks.REMOTE_TRANSMISSION_POLE.getKey())
.add(ModBlocks.TESLA_TOWER.getKey())
.add(ModBlocks.OVERSEER_BLOCK.getKey());

provider.addTag(ModBlockTags.MEKANISM_CARDBOARD_BOX_BLACKLIST)
.add(ModBlocks.GIANT_ANVIL.getKey())
.add(ModBlocks.TRANSMISSION_POLE.getKey())
.add(ModBlocks.REMOTE_TRANSMISSION_POLE.getKey())
.add(ModBlocks.TESLA_TOWER.getKey())
.add(ModBlocks.OVERSEER_BLOCK.getKey());
}
}
1 change: 1 addition & 0 deletions src/main/java/dev/dubhe/anvilcraft/init/ModBlockTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class ModBlockTags {
public static final TagKey<Block> REDSTONE_TORCH = bind("redstone_torch");
public static final TagKey<Block> MUSHROOM_BLOCK = bind("mushroom_block");
public static final TagKey<Block> CANT_BROKEN_ANVIL = bind("cant_broken_anvil");
public static final TagKey<Block> NON_MAGNETIC = bind("non_magnetic");
public static final TagKey<Block> HAMMER_REMOVABLE = bind("hammer_removable");
public static final TagKey<Block> HAMMER_CHANGEABLE = bind("hammer_changeable");
public static final TagKey<Block> OVERSEER_BASE = bind("overseer_base");
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/dev/dubhe/anvilcraft/init/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,12 @@ public class ModBlocks {
.blockstate((ctx, provider) -> {
})
.simpleItem()
.tag(BlockTags.ANVIL,
ModBlockTags.CANT_BROKEN_ANVIL,
BlockTags.MINEABLE_WITH_PICKAXE)
.tag(
BlockTags.ANVIL,
ModBlockTags.NON_MAGNETIC,
ModBlockTags.CANT_BROKEN_ANVIL,
BlockTags.MINEABLE_WITH_PICKAXE
)
.register();

public static final BlockEntry<? extends Block> ROYAL_ANVIL = REGISTRATE
Expand Down Expand Up @@ -1111,7 +1114,7 @@ public class ModBlocks {
public static final BlockEntry<BlockComparatorBlock> BLOCK_COMPARATOR = REGISTRATE
.block("block_comparator", BlockComparatorBlock::new)
.initialProperties(() -> Blocks.OBSERVER)
.properties(p -> p.noOcclusion())
.properties(BlockBehaviour.Properties::noOcclusion)
.tag(BlockTags.MINEABLE_WITH_PICKAXE)
.recipe((ctx, provider) -> {
ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, ctx.get())
Expand All @@ -1132,7 +1135,7 @@ public class ModBlocks {
public static final BlockEntry<ItemDetectorBlock> ITEM_DETECTOR = REGISTRATE
.block("item_detector", ItemDetectorBlock::new)
.initialProperties(() -> Blocks.DAYLIGHT_DETECTOR)
.properties(p -> p.noOcclusion())
.properties(BlockBehaviour.Properties::noOcclusion)
.tag(BlockTags.MINEABLE_WITH_PICKAXE)
.recipe((ctx, provider) -> {
ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, ctx.get())
Expand Down Expand Up @@ -1343,7 +1346,7 @@ public class ModBlocks {
public static final BlockEntry<MineralFountainBlock> MINERAL_FOUNTAIN = REGISTRATE
.block("mineral_fountain", MineralFountainBlock::new)
.initialProperties(() -> Blocks.REINFORCED_DEEPSLATE)
.properties(properties -> properties.noLootTable())
.properties(BlockBehaviour.Properties::noLootTable)
.simpleItem()
.blockstate((context, provider) -> provider.simpleBlock(
context.get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public void tick(
}

@Override

public void neighborChanged(
@NotNull BlockState state,
@NotNull Level level,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.llamalad7.mixinextras.sugar.Local;
import dev.dubhe.anvilcraft.api.event.anvil.AnvilEvent;
import dev.dubhe.anvilcraft.init.ModBlockTags;
import dev.dubhe.anvilcraft.init.ModBlocks;

import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -67,7 +68,7 @@ private void anvilPerFallOnGround(CallbackInfo ci) {
)
private void anvilFallOnGround(CallbackInfo ci, @Local BlockPos blockPos) {
if (this.level().isClientSide()) return;
if (!this.blockState.is(BlockTags.ANVIL)) return;
if (!this.blockState.is(BlockTags.ANVIL) || this.blockState.is(ModBlockTags.NON_MAGNETIC)) return;
FallingBlockEntity entity = (FallingBlockEntity) (Object) this;
AnvilEvent.OnLand event = new AnvilEvent.OnLand(this.level(), blockPos, entity, this.anvilcraft$fallDistance);
NeoForge.EVENT_BUS.post(event);
Expand Down
Loading