[全流程完成]

This commit is contained in:
1820982382
2026-08-17 15:15:04 +08:00
parent 286fc2d2c3
commit 13b981a916
47 changed files with 920 additions and 333 deletions
@@ -1,10 +1,12 @@
package thaumicenergistics.common.blocks;
import java.util.List;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
@@ -14,10 +16,8 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.phys.BlockHitResult;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.aspects.IEssentiaContainerItem;
import thaumicenergistics.common.tiles.ThETileBase;
import thaumicenergistics.common.tiles.TileEssentiaVibrationChamber;
@@ -43,20 +43,16 @@ public abstract class OrientableEntityBlock extends Block implements EntityBlock
@Override
public abstract BlockEntity newBlockEntity(BlockPos pos, BlockState state);
/**
* 谐振仓:通配吸力模式,不再需要安瓿瓶切换燃料类型。
* 放行默认交互(若后续添加 GUI 则走 getMenuProvider)。
*/
@Override
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (level.isClientSide()) return ItemInteractionResult.SUCCESS;
BlockEntity be = level.getBlockEntity(pos);
if (!(be instanceof TileEssentiaVibrationChamber chamber)) return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
// 检查手持物品是否为源质安瓿瓶
if (!(stack.getItem() instanceof IEssentiaContainerItem container)) return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
AspectList aspects = container.getAspects(stack);
if (aspects == null || aspects.size() == 0) return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
Aspect aspect = aspects.getAspects()[0];
if (aspect == Aspect.FIRE || aspect == Aspect.ENERGY) {
chamber.setSuctionType(aspect);
return ItemInteractionResult.SUCCESS;
}
// 通配吸力:无需切换,直接放行
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
@@ -68,4 +64,12 @@ public abstract class OrientableEntityBlock extends Block implements EntityBlock
}
super.onRemove(state, level, pos, newState, moved);
}
/**
* 挖掘掉落方块自身(不导出方块实体 NBT)。
*/
@Override
public List<ItemStack> getDrops(BlockState state, LootParams.Builder builder) {
return List.of(new ItemStack(this));
}
}