diff --git a/common/src/main/java/dev/dubhe/anvilcraft/api/tooltip/HudTooltipManager.java b/common/src/main/java/dev/dubhe/anvilcraft/api/tooltip/HudTooltipManager.java index 86ab16bab..e16f8e0c6 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/api/tooltip/HudTooltipManager.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/api/tooltip/HudTooltipManager.java @@ -33,6 +33,7 @@ public class HudTooltipManager { static { INSTANCE.registerTooltip(new PowerComponentTooltipProvider()); INSTANCE.registerAffectRange(new AffectRangeProviderImpl()); + INSTANCE.registerTooltip(new RubyPrismTooltipProvider()); } private void registerAffectRange(AffectRangeProviderImpl affectRangeProvider) { diff --git a/common/src/main/java/dev/dubhe/anvilcraft/api/tooltip/RubyPrismTooltipProvider.java b/common/src/main/java/dev/dubhe/anvilcraft/api/tooltip/RubyPrismTooltipProvider.java new file mode 100644 index 000000000..0d36befca --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/api/tooltip/RubyPrismTooltipProvider.java @@ -0,0 +1,35 @@ +package dev.dubhe.anvilcraft.api.tooltip; + +import dev.dubhe.anvilcraft.block.entity.RubyPrismBlockEntity; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; + +public class RubyPrismTooltipProvider implements TooltipProvider { + RubyPrismTooltipProvider() {} + + @Override + public boolean accepts(BlockEntity entity) { + return entity instanceof RubyPrismBlockEntity; + } + + @Override + public List tooltip(BlockEntity e) { + if (!(e instanceof RubyPrismBlockEntity rubyPrismBlockEntity)) return null; + final List lines = new ArrayList<>(); + lines.add(Component.translatable("tooltip.anvilcraft.ruby_prism.power", rubyPrismBlockEntity.laserLevel)); + return lines; + } + + @Override + public ItemStack icon(BlockEntity entity) { + return entity.getBlockState().getBlock().asItem().getDefaultInstance(); + } + + @Override + public int priority() { + return 0; + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/ItemCollectorBlock.java b/common/src/main/java/dev/dubhe/anvilcraft/block/ItemCollectorBlock.java index bd6d3a84d..b69ab0c27 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/block/ItemCollectorBlock.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/ItemCollectorBlock.java @@ -3,7 +3,6 @@ import dev.dubhe.anvilcraft.api.depository.FilteredItemDepository; import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable; import dev.dubhe.anvilcraft.api.power.IPowerComponent; -import dev.dubhe.anvilcraft.block.entity.AutoCrafterBlockEntity; import dev.dubhe.anvilcraft.block.entity.ItemCollectorBlockEntity; import dev.dubhe.anvilcraft.init.ModBlockEntities; import dev.dubhe.anvilcraft.init.ModItems; diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/RedhotMetalBlock.java b/common/src/main/java/dev/dubhe/anvilcraft/block/RedhotMetalBlock.java index f332361ae..378a37cfb 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/block/RedhotMetalBlock.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/RedhotMetalBlock.java @@ -1,6 +1,5 @@ package dev.dubhe.anvilcraft.block; -import dev.dubhe.anvilcraft.init.ModBlocks; import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.Entity; diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/RubyLaserBlock.java b/common/src/main/java/dev/dubhe/anvilcraft/block/RubyLaserBlock.java new file mode 100644 index 000000000..c55ac7d1c --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/RubyLaserBlock.java @@ -0,0 +1,125 @@ +package dev.dubhe.anvilcraft.block; + +import dev.dubhe.anvilcraft.api.hammer.IHammerChangeableBlock; +import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable; +import dev.dubhe.anvilcraft.api.power.IPowerComponent; +import dev.dubhe.anvilcraft.api.power.IPowerComponent.Switch; +import dev.dubhe.anvilcraft.block.entity.RubyLaserBlockEntity; +import dev.dubhe.anvilcraft.init.ModBlockEntities; +import javax.annotation.Nonnull; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.BaseEntityBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.DirectionalBlock; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityTicker; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class RubyLaserBlock extends BaseEntityBlock implements IHammerRemovable, + IHammerChangeableBlock { + public static final VoxelShape UP_MODEL = + Shapes.or( + Block.box(4, 3, 4, 12, 13, 12), + Block.box(5, 13, 5, 11, 16, 11), + Block.box(3, 0, 3, 13, 3, 13)); + public static final VoxelShape DOWN_MODEL = + Shapes.or( + Block.box(4, 3, 4, 12, 13, 12), + Block.box(5, 0, 5, 11, 3, 11), + Block.box(3, 13, 3, 13, 16, 13)); + public static final VoxelShape NORTH_MODEL = + Shapes.or( + Block.box(4, 4, 3, 12, 12, 13), + Block.box(5, 5, 0, 11, 11, 3), + Block.box(3, 3, 13, 13, 13, 16)); + public static final VoxelShape SOUTH_MODEL = + Shapes.or( + Block.box(4, 4, 3, 12, 12, 13), + Block.box(5, 5, 13, 11, 11, 16), + Block.box(3, 3, 0, 13, 13, 3)); + public static final VoxelShape WEST_MODEL = + Shapes.or( + Block.box(3, 4, 4, 13, 12, 12), + Block.box(0, 5, 5, 3, 11, 11), + Block.box(13, 3, 3, 16, 13, 13)); + public static final VoxelShape EAST_MODEL = + Shapes.or( + Block.box(3, 4, 4, 13, 12, 12), + Block.box(13, 5, 5, 16, 11, 11), + Block.box(0, 3, 3, 3, 13, 13)); + public static final DirectionProperty FACING = DirectionalBlock.FACING; + public static final BooleanProperty OVERLOAD = IPowerComponent.OVERLOAD; + public static final EnumProperty SWITCH = IPowerComponent.SWITCH; + + /** + * 方块状态注册 + */ + public RubyLaserBlock(Properties properties) { + super(properties); + this.registerDefaultState( + this.stateDefinition.any() + .setValue(FACING, Direction.DOWN) + .setValue(OVERLOAD, false) + .setValue(SWITCH, Switch.OFF)); + } + + @Override + protected void createBlockStateDefinition( + @NotNull StateDefinition.Builder builder) { + builder.add(FACING).add(OVERLOAD).add(SWITCH); + } + + @Nullable + @Override + public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { + return RubyLaserBlockEntity.createBlockEntity(ModBlockEntities.RUBY_LASER.get(), pos, state); + } + + @Override + public @NotNull VoxelShape getShape(@NotNull BlockState state, @NotNull BlockGetter level, @NotNull BlockPos pos, + @NotNull CollisionContext context) { + return switch (state.getValue(FACING)) { + case UP -> UP_MODEL; + case DOWN -> DOWN_MODEL; + case NORTH -> NORTH_MODEL; + case SOUTH -> SOUTH_MODEL; + case WEST -> WEST_MODEL; + case EAST -> EAST_MODEL; + }; + } + + @Override + public @Nonnull RenderShape getRenderShape(@Nonnull BlockState state) { + return RenderShape.MODEL; + } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext context) { + return this.defaultBlockState().setValue(FACING, context.getNearestLookingDirection()); + } + + @Nullable + @Override + public BlockEntityTicker getTicker( + @NotNull Level level, @NotNull BlockState state, @NotNull BlockEntityType type + ) { + if (level.isClientSide) return null; + return createTickerHelper(type, ModBlockEntities.RUBY_LASER.get(), + (level1, pos, state1, entity) -> entity.tick(level1)); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/RubyPrismBlock.java b/common/src/main/java/dev/dubhe/anvilcraft/block/RubyPrismBlock.java new file mode 100644 index 000000000..23a680f31 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/RubyPrismBlock.java @@ -0,0 +1,117 @@ +package dev.dubhe.anvilcraft.block; + +import dev.dubhe.anvilcraft.api.hammer.IHammerChangeableBlock; +import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable; +import dev.dubhe.anvilcraft.block.entity.RubyPrismBlockEntity; +import dev.dubhe.anvilcraft.init.ModBlockEntities; +import javax.annotation.Nonnull; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.BaseEntityBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.DirectionalBlock; +import net.minecraft.world.level.block.RenderShape; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityTicker; +import net.minecraft.world.level.block.entity.BlockEntityType; +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.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class RubyPrismBlock extends BaseEntityBlock implements IHammerRemovable, + IHammerChangeableBlock { + public static final VoxelShape UP_MODEL = + Shapes.or( + Block.box(0, 0, 0, 16, 4, 16), + Block.box(2, 4, 2, 14, 14, 14), + Block.box(4, 14, 4, 12, 16, 12)); + public static final VoxelShape DOWN_MODEL = + Shapes.or( + Block.box(0, 12, 0, 16, 16, 16), + Block.box(2, 2, 2, 14, 12, 14), + Block.box(4, 0, 4, 12, 2, 12)); + public static final VoxelShape NORTH_MODEL = + Shapes.or( + Block.box(0, 0, 12, 16, 16, 16), + Block.box(2, 2, 2, 14, 14, 12), + Block.box(4, 4, 0, 12, 12, 2)); + public static final VoxelShape SOUTH_MODEL = + Shapes.or( + Block.box(0, 0, 0, 16, 16, 4), + Block.box(2, 2, 4, 14, 14, 14), + Block.box(4, 4, 14, 12, 12, 16)); + public static final VoxelShape WEST_MODEL = + Shapes.or( + Block.box(12, 0, 0, 16, 16, 16), + Block.box(2, 2, 2, 12, 14, 14), + Block.box(0, 4, 4, 2, 12, 12)); + public static final VoxelShape EAST_MODEL = + Shapes.or( + Block.box(0, 0, 0, 4, 16, 16), + Block.box(4, 2, 2, 14, 14, 14), + Block.box(14, 4, 4, 16, 12, 12)); + public static final DirectionProperty FACING = DirectionalBlock.FACING; + + /** + * 方块状态注册 + */ + public RubyPrismBlock(Properties properties) { + super(properties); + this.registerDefaultState( + this.stateDefinition.any() + .setValue(FACING, Direction.DOWN)); + } + + @Override + protected void createBlockStateDefinition( + @NotNull StateDefinition.Builder builder) { + builder.add(FACING); + } + + @Nullable + @Override + public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { + return RubyPrismBlockEntity.createBlockEntity(ModBlockEntities.RUBY_PRISM.get(), pos, state); + } + + @Override + public @NotNull VoxelShape getShape(@NotNull BlockState state, @NotNull BlockGetter level, @NotNull BlockPos pos, + @NotNull CollisionContext context) { + return switch (state.getValue(FACING)) { + case UP -> UP_MODEL; + case DOWN -> DOWN_MODEL; + case NORTH -> NORTH_MODEL; + case SOUTH -> SOUTH_MODEL; + case WEST -> WEST_MODEL; + case EAST -> EAST_MODEL; + }; + } + + @Override + public @Nonnull RenderShape getRenderShape(@Nonnull BlockState state) { + return RenderShape.MODEL; + } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext context) { + return this.defaultBlockState().setValue(FACING, context.getNearestLookingDirection()); + } + + @Nullable + @Override + public BlockEntityTicker getTicker( + @NotNull Level level, @NotNull BlockState state, @NotNull BlockEntityType type + ) { + if (level.isClientSide) return null; + return createTickerHelper(type, ModBlockEntities.RUBY_PRISM.get(), + (level1, pos, state1, entity) -> entity.tick(level1)); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/BaseLaserBlockEntity.java b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/BaseLaserBlockEntity.java new file mode 100644 index 000000000..962e3fd26 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/BaseLaserBlockEntity.java @@ -0,0 +1,236 @@ +package dev.dubhe.anvilcraft.block.entity; + +import dev.dubhe.anvilcraft.AnvilCraft; +import dev.dubhe.anvilcraft.api.depository.IItemDepository; +import dev.dubhe.anvilcraft.api.depository.ItemDepositoryHelper; +import dev.dubhe.anvilcraft.init.ModBlockTags; +import dev.dubhe.anvilcraft.network.LaserEmitPack; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.entity.EntityTypeTest; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; + +public abstract class BaseLaserBlockEntity extends BlockEntity { + private final HashMap levelToTimeMap = new HashMap<>() {{ + put(1, 24); + put(2, 6); + put(3, 2); + put(4, 1); + }}; + protected int maxTransmissionDistance = 128; + protected int tickCount = 0; + + protected HashSet irradiateSelfLaserBlockSet = new HashSet<>(); + public BlockPos irradiateBlockPos = null; + public int laserLevel = 0; + + public BaseLaserBlockEntity(BlockEntityType type, + BlockPos pos, BlockState blockState) { + super(type, pos, blockState); + } + + private boolean canPassThrough(Direction direction, BlockPos blockPos) { + if (level == null) return false; + BlockState blockState = level.getBlockState(blockPos); + if (blockState.is(ModBlockTags.LASE_CAN_PASS_THROUGH) + || blockState.is(ModBlockTags.GLASS_BLOCKS) + || blockState.is(ModBlockTags.FORGE_GLASS_BLOCKS) + || blockState.is(ModBlockTags.GLASS_PANES) + || blockState.is(ModBlockTags.FORGE_GLASS_PANES) + || blockState.is(BlockTags.REPLACEABLE)) return true; + if (!AnvilCraft.config.isLaserDoImpactChecking) return false; + AABB laseBoundingBox = switch (direction.getAxis()) { + case X -> Block.box(0, 7, 7, 16, 9, 9).bounds(); + case Y -> Block.box(7, 0, 7, 9, 16, 9).bounds(); + case Z -> Block.box(7, 7, 0, 9, 9, 16).bounds(); + }; + return blockState.getCollisionShape(level, blockPos).toAabbs().stream().noneMatch( + laseBoundingBox::intersects); + } + + private BlockPos getIrradiateBlockPos(int expectedLength, Direction direction, BlockPos originPos) { + for (int length = 1; length <= expectedLength; length++) { + if (!canPassThrough(direction, originPos.relative(direction, length))) + return originPos.relative(direction, length); + } + return originPos.relative(direction, expectedLength); + } + + protected int getBaseLaserLevel() { + return 1; + } + + protected int getLaserLevel() { + return getBaseLaserLevel() + + irradiateSelfLaserBlockSet.stream().mapToInt(BaseLaserBlockEntity::getLaserLevel).sum(); + } + + /** + * 发射激光 + */ + public void emitLaser(Direction direction) { + if (level == null) return; + BlockPos tempIrradiateBlockPos = getIrradiateBlockPos(maxTransmissionDistance, direction, getBlockPos()); + if (!tempIrradiateBlockPos.equals(irradiateBlockPos)) { + if (irradiateBlockPos != null + && level.getBlockEntity(irradiateBlockPos) + instanceof BaseLaserBlockEntity lastIrradiatedLaserBlockEntity) + lastIrradiatedLaserBlockEntity.onCancelingIrradiation(this); + } + if (level.getBlockEntity(tempIrradiateBlockPos) + instanceof BaseLaserBlockEntity irradiatedLaserBlockEntity + && !isInIrradiateSelfLaserBlockSet(irradiatedLaserBlockEntity)) + irradiatedLaserBlockEntity.onIrradiated(this); + irradiateBlockPos = tempIrradiateBlockPos; + + if (!(level instanceof ServerLevel serverLevel)) return; + laserLevel = getLaserLevel(); + AABB trackBoundingBox = + new AABB(getBlockPos().relative(direction).getCenter().add(-0.0625, -0.0625, -0.0625), + irradiateBlockPos.relative(direction.getOpposite()).getCenter().add(0.0625, 0.0625, 0.0625) + ); + int hurt = Math.min(16, laserLevel - 4); + if (hurt > 0) { + level.getEntities(EntityTypeTest.forClass(LivingEntity.class), trackBoundingBox, Entity::isAlive) + .forEach(livingEntity -> livingEntity.hurt(level.damageSources().generic(), hurt)); + } + BlockState irradiateBlock = level.getBlockState(irradiateBlockPos); + List drops = Block.getDrops(irradiateBlock, serverLevel, irradiateBlockPos, + level.getBlockEntity(irradiateBlockPos)); + int coldDown = levelToTimeMap.containsKey(Math.min(16, laserLevel)) + ? levelToTimeMap.get(Math.min(16, laserLevel)) * 20 : Integer.MAX_VALUE; + if (tickCount >= coldDown) { + tickCount = 0; + if (irradiateBlock.is(ModBlockTags.FORGE_ORES) || irradiateBlock.is(ModBlockTags.ORES)) { + Vec3 blockPos = getBlockPos().relative(direction.getOpposite()).getCenter(); + IItemDepository depository = ItemDepositoryHelper.getItemDepository( + getLevel(), + getBlockPos().relative(this.getDirection().getOpposite()), + this.getDirection() + ); + drops.forEach(itemStack -> { + if (depository != null) { + ItemStack outItemStack = ItemDepositoryHelper.insertItem(depository, + itemStack, true); + if (outItemStack.isEmpty()) { + ItemDepositoryHelper.insertItem(depository, itemStack, false); + } else + level.addFreshEntity(new ItemEntity( + level, + blockPos.x, + blockPos.y, + blockPos.z, + outItemStack + )); + } else + level.addFreshEntity(new ItemEntity( + level, + blockPos.x, + blockPos.y, + blockPos.z, + itemStack + )); + }); + if (irradiateBlock.is(Blocks.ANCIENT_DEBRIS)) + level.setBlockAndUpdate(irradiateBlockPos, Blocks.NETHERRACK.defaultBlockState()); + else if (irradiateBlock.is(ModBlockTags.ORES_IN_GROUND_DEEPSLATE) + || irradiateBlock.is(ModBlockTags.FORGE_ORES_IN_GROUND_DEEPSLATE)) + level.setBlockAndUpdate(irradiateBlockPos, Blocks.DEEPSLATE.defaultBlockState()); + else if (irradiateBlock.is(ModBlockTags.ORES_IN_GROUND_NETHERRACK) + || irradiateBlock.is(ModBlockTags.FORGE_ORES_IN_GROUND_NETHERRACK)) + level.setBlockAndUpdate(irradiateBlockPos, Blocks.NETHERRACK.defaultBlockState()); + else level.setBlockAndUpdate(irradiateBlockPos, Blocks.STONE.defaultBlockState()); + /* else { + if (level.getBlockState(irradiateBlockPos).getBlock().defaultDestroyTime() >= 0 + && !(level.getBlockEntity(irradiateBlockPos) instanceof BaseLaserBlockEntity)) { + level.getBlockState(irradiateBlockPos).getBlock() + .playerWillDestroy( + level, + irradiateBlockPos, + level.getBlockState(irradiateBlockPos), + anvilCraftBlockPlacer.getPlayer()); + level.destroyBlock(irradiateBlockPos, false); + } + }*/ + } + } + } + + /** + * 检测光学原件是否在链接表中 + */ + public boolean isInIrradiateSelfLaserBlockSet(BaseLaserBlockEntity baseLaserBlockEntity) { + return baseLaserBlockEntity == this + || irradiateSelfLaserBlockSet.contains(baseLaserBlockEntity) + || irradiateSelfLaserBlockSet.stream().anyMatch(baseLaserBlockEntity1 -> + baseLaserBlockEntity1.isInIrradiateSelfLaserBlockSet(baseLaserBlockEntity)); + } + + public void onIrradiated(BaseLaserBlockEntity baseLaserBlockEntity) { + irradiateSelfLaserBlockSet.add(baseLaserBlockEntity); + } + + /** + * 当方块被取消激光照射时调用 + */ + public void onCancelingIrradiation(BaseLaserBlockEntity baseLaserBlockEntity) { + irradiateSelfLaserBlockSet.remove(baseLaserBlockEntity); + BlockPos tempIrradiateBlockPos = irradiateBlockPos; + irradiateBlockPos = null; + if (level == null) return; + if (tempIrradiateBlockPos == null) return; + if (!(level.getBlockEntity(tempIrradiateBlockPos) instanceof BaseLaserBlockEntity irradiateBlockEntity)) return; + irradiateBlockEntity.onCancelingIrradiation(this); + } + + public void tick(@NotNull Level level) { + new LaserEmitPack(laserLevel, getBlockPos(), irradiateBlockPos).broadcast(); + tickCount++; + } + + public boolean isSwitch() { + return false; + } + + public Direction getDirection() { + return Direction.UP; + } + + @Override + public void setRemoved() { + super.setRemoved(); + if (level == null) return; + if (irradiateBlockPos == null) return; + if (!(level.getBlockEntity(irradiateBlockPos) instanceof BaseLaserBlockEntity irradiateBlockEntity)) return; + irradiateBlockEntity.onCancelingIrradiation(this); + } + + /** + * 为了适配forge中修改的渲染逻辑所添加的函数 + * 返回一个无限碰撞箱 + * + * @return forge中为原版信标生成的无限碰撞箱 + */ + @SuppressWarnings("unused") + public AABB getRenderBoundingBox() { + return new AABB(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, + Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/RubyLaserBlockEntity.java b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/RubyLaserBlockEntity.java new file mode 100644 index 000000000..e326062d4 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/RubyLaserBlockEntity.java @@ -0,0 +1,85 @@ +package dev.dubhe.anvilcraft.block.entity; + +import dev.dubhe.anvilcraft.api.power.IPowerConsumer; +import dev.dubhe.anvilcraft.api.power.PowerGrid; +import dev.dubhe.anvilcraft.block.RubyLaserBlock; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; + +@Getter +@Setter +public class RubyLaserBlockEntity extends BaseLaserBlockEntity implements IPowerConsumer { + private PowerGrid grid; + + private RubyLaserBlockEntity(BlockEntityType type, + BlockPos pos, BlockState blockState) { + super(type, pos, blockState); + } + + public static @NotNull RubyLaserBlockEntity createBlockEntity( + BlockEntityType type, BlockPos pos, BlockState blockState + ) { + return new RubyLaserBlockEntity(type, pos, blockState); + } + + @Override + public void tick(@NotNull Level level) { + if (getGrid() != null + && getBlockState().getValue(RubyLaserBlock.OVERLOAD) == getGrid().isWork()) + level.setBlock( + getPos(), + getBlockState() + .setValue(OVERLOAD, !getGrid().isWork()), + 2); + if (level.hasNeighborSignal(getBlockPos()) == (getBlockState().getValue(SWITCH) == Switch.ON)) + level.setBlock( + getPos(), + getBlockState() + .setValue(SWITCH, level.hasNeighborSignal(getBlockPos()) ? Switch.OFF : Switch.ON), + 2); + if (isSwitch()) emitLaser(getDirection()); + else { + if (irradiateBlockPos != null + && level.getBlockEntity(irradiateBlockPos) instanceof BaseLaserBlockEntity irradiateBlockEntity) + irradiateBlockEntity.onCancelingIrradiation(irradiateBlockEntity); + irradiateBlockPos = null; + } + super.tick(level); + } + + @Override + public boolean isSwitch() { + return getBlockState().getValue(RubyLaserBlock.SWITCH) == Switch.ON + && !getBlockState().getValue(RubyLaserBlock.OVERLOAD); + } + + @Override + public void onIrradiated(BaseLaserBlockEntity baseLaserBlockEntity) { + } + + @Override + public Level getCurrentLevel() { + return level; + } + + @Override + public @NotNull BlockPos getPos() { + return getBlockPos(); + } + + @Override + public int getInputPower() { + return 16; + } + + @Override + public Direction getDirection() { + return this.getBlockState().getValue(RubyLaserBlock.FACING); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/RubyPrismBlockEntity.java b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/RubyPrismBlockEntity.java new file mode 100644 index 000000000..96b946957 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/RubyPrismBlockEntity.java @@ -0,0 +1,56 @@ +package dev.dubhe.anvilcraft.block.entity; + +import dev.dubhe.anvilcraft.block.RubyPrismBlock; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; + +public class RubyPrismBlockEntity extends BaseLaserBlockEntity { + private boolean isOverload = false; + + private RubyPrismBlockEntity(BlockEntityType type, + BlockPos pos, BlockState blockState) { + super(type, pos, blockState); + } + + public static @NotNull RubyPrismBlockEntity createBlockEntity( + BlockEntityType type, BlockPos pos, BlockState blockState + ) { + return new RubyPrismBlockEntity(type, pos, blockState); + } + + public void tick(@NotNull Level level) { + if (isSwitch()) emitLaser(getDirection()); + super.tick(level); + } + + @Override + protected int getBaseLaserLevel() { + return 0; + } + + @Override + public boolean isSwitch() { + return isOverload; + } + + @Override + public void onCancelingIrradiation(BaseLaserBlockEntity baseLaserBlockEntity) { + isOverload = false; + super.onCancelingIrradiation(baseLaserBlockEntity); + } + + @Override + public void onIrradiated(BaseLaserBlockEntity baseLaserBlockEntity) { + isOverload = true; + super.onIrradiated(baseLaserBlockEntity); + } + + @Override + public Direction getDirection() { + return getBlockState().getValue(RubyPrismBlock.FACING); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/renderer/blockentity/LaseRenderer.java b/common/src/main/java/dev/dubhe/anvilcraft/client/renderer/blockentity/LaseRenderer.java new file mode 100644 index 000000000..fc3218474 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/renderer/blockentity/LaseRenderer.java @@ -0,0 +1,192 @@ +package dev.dubhe.anvilcraft.client.renderer.blockentity; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import dev.dubhe.anvilcraft.block.entity.BaseLaserBlockEntity; +import dev.dubhe.anvilcraft.block.entity.RubyLaserBlockEntity; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; +import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; + +public class LaseRenderer implements BlockEntityRenderer { + + @SuppressWarnings("unused") + public LaseRenderer(BlockEntityRendererProvider.Context context) { + } + + @Override + public void render(@NotNull BaseLaserBlockEntity blockEntity, float partialTick, @NotNull PoseStack poseStack, + @NotNull MultiBufferSource buffer, int packedLight, int packedOverlay) { + if (blockEntity.getLevel() == null) return; + if (blockEntity.irradiateBlockPos == null) return; + final TextureAtlasSprite sprite = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS) + .apply(new ResourceLocation("block/white_concrete")); + poseStack.pushPose(); + VertexConsumer consumer = + buffer.getBuffer(RenderType.translucent()); + float length = + (float) (blockEntity.irradiateBlockPos.getCenter().distanceTo(blockEntity.getBlockPos().getCenter()) - 0.5); + poseStack.translate(0.5f, 0.5f, 0.5); + float offest = 0; + if (blockEntity instanceof RubyLaserBlockEntity) offest = 0.489f; + switch (blockEntity.getDirection()) { + case EAST -> { + renderBox( + consumer, poseStack, + -offest, -0.0625f, -0.0625f, length, 0.0625f, 0.0625f, sprite); + renderBox( + consumer, poseStack, + length, -0.0625f, -0.0625f, length + 0.3f, 0.0625f, 0.0625f, 0.35f, sprite); + renderBox( + consumer, poseStack, + length + 0.3f, -0.0625f, -0.0625f, length + 0.57f, 0.0625f, 0.0625f, 0.15f, sprite); + } + case WEST -> { + renderBox( + consumer, poseStack, + -length, -0.0625f, -0.0625f, offest, 0.0625f, 0.0625f, sprite); + renderBox( + consumer, poseStack, + -length - 0.3f, -0.0625f, -0.0625f, -length, -0.0625f, -0.0625f, 0.35f, sprite); + renderBox( + consumer, poseStack, + -length - 0.57f, -0.0625f, -0.0625f, -length - 0.3f, 0.0625f, 0.0625f, 0.15f, sprite); + } + case SOUTH -> { + renderBox( + consumer, poseStack, + -0.0625f, -0.0625f, -offest, 0.0625f, 0.0625f, length, sprite); + renderBox( + consumer, poseStack, + -0.0625f, -0.0625f, length, 0.0625f, 0.0625f, length + 0.3f, 0.35f, sprite); + renderBox( + consumer, poseStack, + -0.0625f, -0.0625f, length + 0.3f, 0.0625f, 0.0625f, length + 0.57f, 0.15f, sprite); + } + case NORTH -> { + renderBox( + consumer, poseStack, + -0.0625f, -0.0625f, -length, 0.0625f, 0.0625f, offest, sprite); + renderBox( + consumer, poseStack, + -0.0625f, -0.0625f, -length - 0.3f, 0.0625f, 0.0625f, -length, 0.35f, sprite); + renderBox( + consumer, poseStack, + -0.0625f, -0.0625f, -length - 0.57f, 0.0625f, 0.0625f, -length - 0.3f, 0.15f, sprite); + } + case UP -> { + renderBox( + consumer, poseStack, + -0.0625f, -offest, -0.0625f, 0.0625f, length, 0.0625f, sprite); + renderBox( + consumer, poseStack, + -0.0625f, length, -0.0625f, 0.0625f, length + 0.3f, 0.0625f, 0.35f, sprite); + renderBox( + consumer, poseStack, + -0.0625f, length + 0.3f, -0.0625f, 0.0625f, length + 0.57f, 0.0625f, 0.15f, sprite); + } + default -> { + renderBox( + consumer, poseStack, + -0.0625f, -length, -0.0625f, 0.0625f, offest, 0.0625f, sprite); + renderBox( + consumer, poseStack, + -0.0625f, -length - 0.3f, -0.0625f, 0.0625f, -length, 0.0625f, 0.35f, sprite); + renderBox( + consumer, poseStack, + -0.0625f, -length - 0.75f, -0.0625f, 0.0625f, -length - 0.3f, 0.0625f, 0.15f, sprite); + } + } + poseStack.popPose(); + } + + private static void renderBox( + VertexConsumer consumer, + @NotNull PoseStack poseStack, + float minX, float minY, float minZ, float maxX, float maxY, float maxZ, TextureAtlasSprite sprite + ) { + renderQuadX(consumer, poseStack, maxX, maxX, minY, minZ, maxY, maxZ, 0.5f, sprite); + renderQuadX(consumer, poseStack, minX, minX, minY, maxZ, maxY, minZ, 0.5f, sprite); + renderQuadY(consumer, poseStack, maxY, maxY, minX, minZ, maxX, maxZ, 0.5f, sprite); + renderQuadY(consumer, poseStack, minY, minY, maxX, minZ, minX, maxZ, 0.5f, sprite); + renderQuadZ(consumer, poseStack, maxZ, maxZ, minX, maxY, maxX, minY, 0.5f, sprite); + renderQuadZ(consumer, poseStack, minZ, minZ, minX, minY, maxX, maxY, 0.5f, sprite); + } + + private static void renderBox( + VertexConsumer consumer, + @NotNull PoseStack poseStack, + float minX, float minY, float minZ, float maxX, float maxY, float maxZ, float a, TextureAtlasSprite sprite + ) { + renderQuadX(consumer, poseStack, maxX, maxX, minY, minZ, maxY, maxZ, a, sprite); + renderQuadX(consumer, poseStack, minX, minX, minY, maxZ, maxY, minZ, a, sprite); + renderQuadY(consumer, poseStack, maxY, maxY, minX, minZ, maxX, maxZ, a, sprite); + renderQuadY(consumer, poseStack, minY, minY, maxX, minZ, minX, maxZ, a, sprite); + renderQuadZ(consumer, poseStack, maxZ, maxZ, minX, maxY, maxX, minY, a, sprite); + renderQuadZ(consumer, poseStack, minZ, minZ, minX, minY, maxX, maxY, a, sprite); + } + + + private static void renderQuadX( + VertexConsumer consumer, + @NotNull PoseStack poseStack, + float minX, float maxX, float minY, float minZ, float maxY, float maxZ, float a, TextureAtlasSprite sprite + ) { + addVertex(consumer, poseStack, minX, maxY, minZ, sprite.getU1(), sprite.getV1(), a); + addVertex(consumer, poseStack, minX, maxY, maxZ, sprite.getU0(), sprite.getV1(), a); + addVertex(consumer, poseStack, maxX, minY, maxZ, sprite.getU0(), sprite.getV0(), a); + addVertex(consumer, poseStack, maxX, minY, minZ, sprite.getU1(), sprite.getV0(), a); + } + + private static void renderQuadY( + VertexConsumer consumer, + @NotNull PoseStack poseStack, + float minY, float maxY, float minX, float minZ, float maxX, float maxZ, float a, TextureAtlasSprite sprite + ) { + addVertex(consumer, poseStack, minX, minY, minZ, sprite.getU1(), sprite.getV1(), a); + addVertex(consumer, poseStack, minX, minY, maxZ, sprite.getU0(), sprite.getV1(), a); + addVertex(consumer, poseStack, maxX, maxY, maxZ, sprite.getU0(), sprite.getV0(), a); + addVertex(consumer, poseStack, maxX, maxY, minZ, sprite.getU1(), sprite.getV0(), a); + } + + private static void renderQuadZ( + VertexConsumer consumer, + @NotNull PoseStack poseStack, + float minZ, float maxZ, float minX, float minY, float maxX, float maxY, float a, TextureAtlasSprite sprite + ) { + addVertex(consumer, poseStack, minX, maxY, minZ, sprite.getU1(), sprite.getV1(), a); + addVertex(consumer, poseStack, maxX, maxY, minZ, sprite.getU0(), sprite.getV1(), a); + addVertex(consumer, poseStack, maxX, minY, maxZ, sprite.getU0(), sprite.getV0(), a); + addVertex(consumer, poseStack, minX, minY, maxZ, sprite.getU1(), sprite.getV0(), a); + } + + private static void addVertex( + @NotNull VertexConsumer consumer, @NotNull PoseStack poseStack, + float x, float y, float z, float u, float v, float a) { + consumer + .vertex(poseStack.last().pose(), x, y, z) + .color(1f, 0.05f, 0.05f, a) + .uv(u, v) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(0xF000F0) + .normal(1, 0, 0) + .endVertex(); + } + + @Override + public int getViewDistance() { + return 256; + } + + @Override + public boolean shouldRenderOffScreen(@NotNull BaseLaserBlockEntity blockEntity) { + return true; + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/config/AnvilCraftConfig.java b/common/src/main/java/dev/dubhe/anvilcraft/config/AnvilCraftConfig.java index ddd5933ae..d929df988 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/config/AnvilCraftConfig.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/config/AnvilCraftConfig.java @@ -108,6 +108,10 @@ public class AnvilCraftConfig implements ConfigData { @ConfigEntry.Gui.CollapsibleObject(startExpanded = true) public PowerConverter powerConverter = new PowerConverter(); + + @ConfigEntry.Gui.Tooltip() + public boolean isLaserDoImpactChecking = true; + public static class PowerConverter implements ConfigData { @Comment("The working interval of power converters") @ConfigEntry.Gui.Tooltip diff --git a/common/src/main/java/dev/dubhe/anvilcraft/data/generator/lang/ScreenLang.java b/common/src/main/java/dev/dubhe/anvilcraft/data/generator/lang/ScreenLang.java index 48cccbf72..b9b19229b 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/data/generator/lang/ScreenLang.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/data/generator/lang/ScreenLang.java @@ -58,6 +58,8 @@ public static void init(RegistrateLangProvider provider) { provider.add("tooltip.anvilcraft.grid_information.overloaded2", "Add more sources or remove the components"); provider.add("tooltip.anvilcraft.grid_information.overloaded3", "with a high stress impact."); + provider.add("tooltip.anvilcraft.ruby_prism.power", "Laser level: %d"); + provider.add("screen.anvilcraft.active_silencer.title", "Active Silencer"); } } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/data/generator/tags/BlockTagLoader.java b/common/src/main/java/dev/dubhe/anvilcraft/data/generator/tags/BlockTagLoader.java index ec4cd8809..a21cb92e9 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/data/generator/tags/BlockTagLoader.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/data/generator/tags/BlockTagLoader.java @@ -90,5 +90,15 @@ public static void init(@NotNull RegistrateTagsProvider provider) { .add(Blocks.BASALT) .add(Blocks.BLACKSTONE) .add(Blocks.END_STONE); + provider.addTag(ModBlockTags.GLASS_BLOCKS).setReplace(false) + .add(ModBlocks.TEMPERING_GLASS.get()); + provider.addTag(ModBlockTags.FORGE_GLASS_BLOCKS).setReplace(false) + .add(ModBlocks.TEMPERING_GLASS.get()); + provider.addTag(ModBlockTags.LASE_CAN_PASS_THROUGH).setReplace(false) + .forceAddTag(ModBlockTags.GLASS_BLOCKS) + .forceAddTag(ModBlockTags.GLASS_PANES) + .forceAddTag(ModBlockTags.FORGE_GLASS_BLOCKS) + .forceAddTag(ModBlockTags.FORGE_GLASS_PANES) + .forceAddTag(BlockTags.REPLACEABLE); } } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/event/PistonMoveBlockListener.java b/common/src/main/java/dev/dubhe/anvilcraft/event/PistonMoveBlockListener.java index 34f7196fa..1b99a63e6 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/event/PistonMoveBlockListener.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/event/PistonMoveBlockListener.java @@ -4,7 +4,6 @@ import dev.dubhe.anvilcraft.api.chargecollector.ChargeCollectorManager.Entry; import dev.dubhe.anvilcraft.block.MagnetBlock; import dev.dubhe.anvilcraft.block.entity.ChargeCollectorBlockEntity; -import dev.dubhe.anvilcraft.init.ModBlocks; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.Level; diff --git a/common/src/main/java/dev/dubhe/anvilcraft/event/ServerEventListener.java b/common/src/main/java/dev/dubhe/anvilcraft/event/ServerEventListener.java index e07417094..7e05d4748 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/event/ServerEventListener.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/event/ServerEventListener.java @@ -1,11 +1,9 @@ package dev.dubhe.anvilcraft.event; -import dev.dubhe.anvilcraft.AnvilCraft; import dev.dubhe.anvilcraft.api.event.SubscribeEvent; import dev.dubhe.anvilcraft.api.event.server.ServerStartedEvent; import dev.dubhe.anvilcraft.api.hammer.HammerManager; import dev.dubhe.anvilcraft.init.ModHammerInits; -import dev.dubhe.anvilcraft.util.EnchantmentDisableUtil; import org.jetbrains.annotations.NotNull; public class ServerEventListener { diff --git a/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlockEntities.java b/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlockEntities.java index 7e5bf1a0d..5ac42aaf7 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlockEntities.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlockEntities.java @@ -18,11 +18,14 @@ import dev.dubhe.anvilcraft.block.entity.MobAmberBlockEntity; import dev.dubhe.anvilcraft.block.entity.RemoteTransmissionPoleBlockEntity; import dev.dubhe.anvilcraft.block.entity.ResentfulAmberBlock; +import dev.dubhe.anvilcraft.block.entity.RubyLaserBlockEntity; +import dev.dubhe.anvilcraft.block.entity.RubyPrismBlockEntity; import dev.dubhe.anvilcraft.block.entity.SimpleChuteBlockEntity; import dev.dubhe.anvilcraft.block.entity.ThermoelectricConverterBlockEntity; import dev.dubhe.anvilcraft.block.entity.TransmissionPoleBlockEntity; import dev.dubhe.anvilcraft.client.renderer.blockentity.CorruptedBeaconRenderer; import dev.dubhe.anvilcraft.client.renderer.blockentity.HasMobBlockRenderer; +import dev.dubhe.anvilcraft.client.renderer.blockentity.LaseRenderer; import static dev.dubhe.anvilcraft.AnvilCraft.REGISTRATE; @@ -131,6 +134,17 @@ public class ModBlockEntities { .validBlocks(ModBlocks.ACTIVE_SILENCER) .register(); + public static final BlockEntityEntry RUBY_PRISM = REGISTRATE + .blockEntity("ruby_prism", RubyPrismBlockEntity::createBlockEntity) + .validBlock(ModBlocks.RUBY_PRISM) + .renderer(() -> LaseRenderer::new) + .register(); + public static final BlockEntityEntry RUBY_LASER = REGISTRATE + .blockEntity("ruby_laser", RubyLaserBlockEntity::createBlockEntity) + .validBlock(ModBlocks.RUBY_LASER) + .renderer(() -> LaseRenderer::new) + .register(); + public static final BlockEntityEntry THERMOELECTRIC_CONVERTER = REGISTRATE .blockEntity("thermoelectric_converter", ThermoelectricConverterBlockEntity::new) .validBlocks(ModBlocks.THERMOELECTRIC_CONVERTER) diff --git a/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlockTags.java b/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlockTags.java index 3fe0d71dd..2b51f1100 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlockTags.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlockTags.java @@ -17,11 +17,26 @@ public class ModBlockTags { public static final TagKey HAMMER_CHANGEABLE = bind("hammer_changeable"); public static final TagKey OVERSEER_BASE = bind("overseer_base"); public static final TagKey BLOCK_DEVOURER_PROBABILITY_DROPPING = bind("block_devourer_probability_dropping"); + public static final TagKey LASE_CAN_PASS_THROUGH = bind("lase_can_pass_though"); + public static final TagKey GLASS_BLOCKS = bindC("glass_blocks"); + public static final TagKey GLASS_PANES = bindC("glass_panes"); + public static final TagKey ORES = bindC("ores"); + public static final TagKey ORES_IN_GROUND_NETHERRACK = bindC("ores_in_ground/netherrack"); + public static final TagKey ORES_IN_GROUND_DEEPSLATE = bindC("ores_in_ground/deepslate"); + public static final TagKey FORGE_GLASS_BLOCKS = bingForge("glass"); + public static final TagKey FORGE_GLASS_PANES = bingForge("glass_panes"); + public static final TagKey FORGE_ORES = bingForge("ores"); + public static final TagKey FORGE_ORES_IN_GROUND_NETHERRACK = bingForge("ores_in_ground/netherrack"); + public static final TagKey FORGE_ORES_IN_GROUND_DEEPSLATE = bingForge("ores_in_ground/deepslate"); private static @NotNull TagKey bindC(String id) { return TagKey.create(Registries.BLOCK, new ResourceLocation("c", id)); } + private static @NotNull TagKey bingForge(String id) { + return TagKey.create(Registries.BLOCK, new ResourceLocation("forge", id)); + } + private static @NotNull TagKey bind(String id) { return TagKey.create(Registries.BLOCK, AnvilCraft.of(id)); } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlocks.java b/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlocks.java index ac7d46204..7fe6eb3f2 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlocks.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlocks.java @@ -4,6 +4,7 @@ import com.tterrag.registrate.util.entry.BlockEntry; import dev.dubhe.anvilcraft.AnvilCraft; import dev.dubhe.anvilcraft.api.power.IPowerComponent; +import dev.dubhe.anvilcraft.api.power.IPowerComponent.Switch; import dev.dubhe.anvilcraft.block.ActiveSilencerBlock; import dev.dubhe.anvilcraft.block.ArrowBlock; import dev.dubhe.anvilcraft.block.AutoCrafterBlock; @@ -47,6 +48,8 @@ import dev.dubhe.anvilcraft.block.RoyalAnvilBlock; import dev.dubhe.anvilcraft.block.RoyalGrindstone; import dev.dubhe.anvilcraft.block.RoyalSmithingTableBlock; +import dev.dubhe.anvilcraft.block.RubyLaserBlock; +import dev.dubhe.anvilcraft.block.RubyPrismBlock; import dev.dubhe.anvilcraft.block.SimpleChuteBlock; import dev.dubhe.anvilcraft.block.StampingPlatformBlock; import dev.dubhe.anvilcraft.block.ThermoelectricConverterBlock; @@ -1747,6 +1750,8 @@ public class ModBlocks { .block("discharger", DischargerBlock::new) .initialProperties(() -> Blocks.IRON_BLOCK) .properties(BlockBehaviour.Properties::noOcclusion) + .blockstate((ctx, provider) -> { + }) .simpleItem() .defaultLoot() .tag(BlockTags.MINEABLE_WITH_PICKAXE) @@ -1952,6 +1957,77 @@ public class ModBlocks { .register(); + public static final BlockEntry RUBY_PRISM = REGISTRATE + .block("ruby_prism", RubyPrismBlock::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .properties(BlockBehaviour.Properties::noOcclusion) + .blockstate((ctx, provider) -> { + }) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) + .pattern("ACA") + .pattern("CBC") + .pattern("AAA") + .define('A', ModItems.ROYAL_STEEL_INGOT) + .define('B', ModBlocks.RUBY_BLOCK) + .define('C', ModItems.RUBY) + .unlockedBy( + AnvilCraftDatagen.hasItem(ModItems.ROYAL_STEEL_INGOT), + AnvilCraftDatagen.has(ModItems.ROYAL_STEEL_INGOT) + ) + .unlockedBy( + AnvilCraftDatagen.hasItem(ModBlocks.RUBY_BLOCK), + AnvilCraftDatagen.has(ModBlocks.RUBY_BLOCK) + ) + .unlockedBy( + AnvilCraftDatagen.hasItem(ModItems.RUBY), + AnvilCraftDatagen.has(ModItems.RUBY) + ) + .save(provider) + ) + .simpleItem() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .register(); + + public static final BlockEntry RUBY_LASER = REGISTRATE + .block("ruby_laser", RubyLaserBlock::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .properties(p -> p.lightLevel(it -> { + if (it.getValue(RubyLaserBlock.SWITCH) == Switch.ON) + return 15; + else return 0; + })) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) + .pattern("ACA") + .pattern("BDB") + .pattern("ACA") + .define('A', ModItems.ROYAL_STEEL_INGOT) + .define('B', ModBlocks.INDUCTION_LIGHT) + .define('C', ModItems.SILVER_INGOT) + .define('D', ModBlocks.RUBY_BLOCK) + .unlockedBy( + AnvilCraftDatagen.hasItem(ModItems.ROYAL_STEEL_INGOT), + AnvilCraftDatagen.has(ModItems.ROYAL_STEEL_INGOT) + ) + .unlockedBy( + AnvilCraftDatagen.hasItem(ModBlocks.INDUCTION_LIGHT), + AnvilCraftDatagen.has(ModBlocks.INDUCTION_LIGHT) + ) + .unlockedBy( + AnvilCraftDatagen.hasItem(ModItems.SILVER_INGOT), + AnvilCraftDatagen.has(ModItems.SILVER_INGOT)) + .unlockedBy( + AnvilCraftDatagen.hasItem(ModBlocks.RUBY_BLOCK), + AnvilCraftDatagen.has(ModBlocks.RUBY_BLOCK) + ) + .save(provider) + ) + .properties(BlockBehaviour.Properties::noOcclusion) + .blockstate((ctx, provider) -> { + }) + .simpleItem() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .register(); + private static @NotNull BlockEntry registerReinforcedConcreteBlock(@NotNull Color color) { return REGISTRATE .block("reinforced_concrete_" + color, ReinforcedConcreteBlock::new) diff --git a/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemGroups.java b/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemGroups.java index d818828fa..85da71f5b 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemGroups.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemGroups.java @@ -148,6 +148,8 @@ public class ModItemGroups { entries.accept(ModBlocks.ACTIVE_SILENCER.asStack()); entries.accept(ModBlocks.BLOCK_PLACER.asStack()); entries.accept(ModBlocks.BLOCK_DEVOURER.asStack()); + entries.accept(ModBlocks.RUBY_LASER.asStack()); + entries.accept(ModBlocks.RUBY_PRISM.asStack()); entries.accept(ModBlocks.OVERSEER_BLOCK.asStack()); entries.accept(ModBlocks.JEWEL_CRAFTING_TABLE.asStack()); entries.accept(ModBlocks.MAGNET_BLOCK.asStack()); diff --git a/common/src/main/java/dev/dubhe/anvilcraft/init/ModNetworks.java b/common/src/main/java/dev/dubhe/anvilcraft/init/ModNetworks.java index 9de021ee7..5fd09a3ac 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModNetworks.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModNetworks.java @@ -4,6 +4,7 @@ import dev.dubhe.anvilcraft.api.network.Network; import dev.dubhe.anvilcraft.network.ClientboundMutedSoundSyncPacket; import dev.dubhe.anvilcraft.network.HammerUsePack; +import dev.dubhe.anvilcraft.network.LaserEmitPack; import dev.dubhe.anvilcraft.network.MachineEnableFilterPack; import dev.dubhe.anvilcraft.network.MachineOutputDirectionPack; import dev.dubhe.anvilcraft.network.PowerGridRemovePack; @@ -75,8 +76,13 @@ public class ModNetworks { ); public static final ResourceLocation MUTED_SOUND_REMOVE = Network.register( - AnvilCraft.of("muted_sound_remove"), - ServerboundRemoveMutedSoundPacket.class, ServerboundRemoveMutedSoundPacket::new + AnvilCraft.of("muted_sound_remove"), + ServerboundRemoveMutedSoundPacket.class, ServerboundRemoveMutedSoundPacket::new + ); + + public static final ResourceLocation LASER_EMIT = Network.register( + AnvilCraft.of("laser_emit"), + LaserEmitPack.class, LaserEmitPack::new ); public static void register() { diff --git a/common/src/main/java/dev/dubhe/anvilcraft/item/EmptyCapacitorItem.java b/common/src/main/java/dev/dubhe/anvilcraft/item/EmptyCapacitorItem.java index 482df25df..b3c06c7da 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/item/EmptyCapacitorItem.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/item/EmptyCapacitorItem.java @@ -1,7 +1,6 @@ package dev.dubhe.anvilcraft.item; import dev.dubhe.anvilcraft.api.item.IChargerChargeable; -import dev.dubhe.anvilcraft.api.item.IChargerDischargeable; import dev.dubhe.anvilcraft.init.ModItems; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; diff --git a/common/src/main/java/dev/dubhe/anvilcraft/network/ClientboundMutedSoundSyncPacket.java b/common/src/main/java/dev/dubhe/anvilcraft/network/ClientboundMutedSoundSyncPacket.java index e9d63ea40..5e37c789c 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/network/ClientboundMutedSoundSyncPacket.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/network/ClientboundMutedSoundSyncPacket.java @@ -1,16 +1,14 @@ package dev.dubhe.anvilcraft.network; import dev.dubhe.anvilcraft.api.network.Packet; -import dev.dubhe.anvilcraft.api.sound.SoundHelper; import dev.dubhe.anvilcraft.client.gui.screen.inventory.ActiveSilencerScreen; import dev.dubhe.anvilcraft.init.ModNetworks; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; -import java.util.List; - public class ClientboundMutedSoundSyncPacket implements Packet { private final List sounds; diff --git a/common/src/main/java/dev/dubhe/anvilcraft/network/LaserEmitPack.java b/common/src/main/java/dev/dubhe/anvilcraft/network/LaserEmitPack.java new file mode 100644 index 000000000..0b603d592 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/network/LaserEmitPack.java @@ -0,0 +1,67 @@ +package dev.dubhe.anvilcraft.network; + +import dev.dubhe.anvilcraft.api.network.Packet; +import dev.dubhe.anvilcraft.block.entity.BaseLaserBlockEntity; +import dev.dubhe.anvilcraft.init.ModNetworks; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.Minecraft; +import net.minecraft.core.BlockPos; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; + +public class LaserEmitPack implements Packet { + private final int lightPowerLevel; + private final BlockPos laserBlockPos; + private final BlockPos irradiateBlockPos; + + /** + * 激光照射网络包 + */ + public LaserEmitPack(int lightPowerLevel, BlockPos laserBlockPos, BlockPos irradiateBlockPos) { + this.lightPowerLevel = lightPowerLevel; + this.laserBlockPos = laserBlockPos; + this.irradiateBlockPos = irradiateBlockPos; + } + + /** + * 激光照射网络包 + */ + public LaserEmitPack(FriendlyByteBuf buf) { + this.lightPowerLevel = buf.readInt(); + this.laserBlockPos = buf.readBlockPos(); + if (buf.readBoolean()) { + this.irradiateBlockPos = null; + return; + } + this.irradiateBlockPos = buf.readBlockPos(); + } + + @Override + public ResourceLocation getType() { + return ModNetworks.LASER_EMIT; + } + + @Override + public void encode(@NotNull FriendlyByteBuf buf) { + buf.writeInt(lightPowerLevel); + buf.writeBlockPos(laserBlockPos); + buf.writeBoolean(irradiateBlockPos == null); + if (irradiateBlockPos != null) + buf.writeBlockPos(irradiateBlockPos); + } + + @Override + @Environment(EnvType.CLIENT) + public void handler() { + Minecraft.getInstance().execute(() -> { + if (Minecraft.getInstance().level != null + && Minecraft.getInstance().level.getBlockEntity(laserBlockPos) + instanceof BaseLaserBlockEntity baseLaserBlockEntity) { + baseLaserBlockEntity.irradiateBlockPos = irradiateBlockPos; + baseLaserBlockEntity.laserLevel = lightPowerLevel; + } + }); + } +} diff --git a/common/src/main/resources/anvilcraft.accesswidener b/common/src/main/resources/anvilcraft.accesswidener index 601382012..cdcfff63a 100644 --- a/common/src/main/resources/anvilcraft.accesswidener +++ b/common/src/main/resources/anvilcraft.accesswidener @@ -24,3 +24,5 @@ accessible field net/minecraft/server/level/ChunkMap updatingChunkMap Lit/unimi/ accessible method net/minecraft/world/item/BlockItem getPlaceSound (Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/sounds/SoundEvent; accessible method net/minecraft/world/level/block/Blocks never (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/EntityType;)Ljava/lang/Boolean; accessible method net/minecraft/world/level/block/Blocks never (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Z +accessible method net/minecraft/util/SortedArraySet findIndex (Ljava/lang/Object;)I +accessible method net/minecraft/util/SortedArraySet getInternal (I)Ljava/lang/Object; \ No newline at end of file diff --git a/common/src/main/resources/assets/anvilcraft/blockstates/ruby_prism.json b/common/src/main/resources/assets/anvilcraft/blockstates/ruby_prism.json new file mode 100644 index 000000000..81334eec9 --- /dev/null +++ b/common/src/main/resources/assets/anvilcraft/blockstates/ruby_prism.json @@ -0,0 +1,30 @@ +{ + "variants": { + "facing=up": { + "model": "anvilcraft:block/ruby_prism" + }, + "facing=down": { + "model": "anvilcraft:block/ruby_prism", + "x": 180 + }, + "facing=south": { + "model": "anvilcraft:block/ruby_prism", + "x": 270 + }, + "facing=west": { + "model": "anvilcraft:block/ruby_prism", + "x": 270, + "y": 90 + }, + "facing=north": { + "model": "anvilcraft:block/ruby_prism", + "x": 270, + "y": 180 + }, + "facing=east": { + "model": "anvilcraft:block/ruby_prism", + "x": 270, + "y": 270 + } + } +} \ No newline at end of file diff --git a/fabric/src/generated/resources/assets/anvilcraft/lang/en_ud.json b/fabric/src/generated/resources/assets/anvilcraft/lang/en_ud.json index 17ce726e6..597c9696e 100644 --- a/fabric/src/generated/resources/assets/anvilcraft/lang/en_ud.json +++ b/fabric/src/generated/resources/assets/anvilcraft/lang/en_ud.json @@ -134,6 +134,8 @@ "block.anvilcraft.royal_smithing_table": "ǝןqɐ⟘ buıɥʇıɯS ןɐʎoᴚ", "block.anvilcraft.royal_steel_block": "ʞɔoןᗺ ןǝǝʇS ןɐʎoᴚ", "block.anvilcraft.ruby_block": "ʞɔoןᗺ ʎqnᴚ", + "block.anvilcraft.ruby_laser": "ɹǝsɐꞀ ʎqnᴚ", + "block.anvilcraft.ruby_prism": "ɯsıɹԀ ʎqnᴚ", "block.anvilcraft.sapphire_block": "ʞɔoןᗺ ǝɹıɥddɐS", "block.anvilcraft.silver_block": "ʞɔoןᗺ ɹǝʌןıS", "block.anvilcraft.simple_chute": "ǝʇnɥƆ ǝןdɯıS", @@ -278,6 +280,7 @@ "text.autoconfig.anvilcraft.option.geodeInterval.@Tooltip": "ǝpoǝb ǝɥʇ ɟo ןɐʌɹǝʇuı ɥɔɹɐǝs ǝɥ⟘", "text.autoconfig.anvilcraft.option.geodeRadius": "snıpɐᴚ ɥɔɹɐǝS ɯnɯıxɐW ǝpoǝ⅁", "text.autoconfig.anvilcraft.option.geodeRadius.@Tooltip": "ǝpoǝb ǝɥʇ ɟo snıpɐɹ ɥɔɹɐǝs ɯnɯıxɐɯ ǝɥ⟘", + "text.autoconfig.anvilcraft.option.isLaserDoImpactChecking": "buıʞɔǝɥƆ ʇɔɐdɯI oᗡ ɹǝsɐꞀ sI", "text.autoconfig.anvilcraft.option.lightningStrikeDepth": "ɥʇdǝᗡ ǝʞıɹʇS buıuʇɥbıꞀ", "text.autoconfig.anvilcraft.option.lightningStrikeDepth.@Tooltip": "ɥɔɐǝɹ uɐɔ ǝʞıɹʇs buıuʇɥbıן ɐ ɥʇdǝp ɯnɯıxɐW", "text.autoconfig.anvilcraft.option.lightningStrikeRadius": "snıpɐᴚ ǝʞıɹʇS buıuʇɥbıꞀ", @@ -349,5 +352,6 @@ "tooltip.anvilcraft.item.tempering_glass": "ʇɔǝןןoɔ uo pǝɹınbǝɹ sןooʇ oN 'ɟooɹd ɹǝdǝǝɹƆ", "tooltip.anvilcraft.item.topaz": "buıuʇɥbıן ɟo ɹǝʍod ǝɥʇ buıuıɐʇuoƆ", "tooltip.anvilcraft.item.transmission_pole": "8 ɟo ǝɔuɐʇsıp uoıssıɯsuɐɹʇ ɐ ɥʇıʍ pıɹb ɹǝʍod ɐ pןınᗺ", - "tooltip.anvilcraft.jade.power_information": "Mʞ %d/%d :pıɹ⅁ ɹǝʍoԀ" + "tooltip.anvilcraft.jade.power_information": "Mʞ %d/%d :pıɹ⅁ ɹǝʍoԀ", + "tooltip.anvilcraft.ruby_prism.power": "%d :ןǝʌǝן ʇɥbıꞀ" } \ No newline at end of file diff --git a/fabric/src/generated/resources/assets/anvilcraft/lang/en_us.json b/fabric/src/generated/resources/assets/anvilcraft/lang/en_us.json index b1dfafa07..f29268c1d 100644 --- a/fabric/src/generated/resources/assets/anvilcraft/lang/en_us.json +++ b/fabric/src/generated/resources/assets/anvilcraft/lang/en_us.json @@ -134,6 +134,8 @@ "block.anvilcraft.royal_smithing_table": "Royal Smithing Table", "block.anvilcraft.royal_steel_block": "Royal Steel Block", "block.anvilcraft.ruby_block": "Ruby Block", + "block.anvilcraft.ruby_laser": "Ruby Laser", + "block.anvilcraft.ruby_prism": "Ruby Prism", "block.anvilcraft.sapphire_block": "Sapphire Block", "block.anvilcraft.silver_block": "Silver Block", "block.anvilcraft.simple_chute": "Simple Chute", @@ -278,6 +280,7 @@ "text.autoconfig.anvilcraft.option.geodeInterval.@Tooltip": "The search interval of the geode", "text.autoconfig.anvilcraft.option.geodeRadius": "Geode Maximum Search Radius", "text.autoconfig.anvilcraft.option.geodeRadius.@Tooltip": "The maximum search radius of the geode", + "text.autoconfig.anvilcraft.option.isLaserDoImpactChecking": "Is Laser Do Impact Checking", "text.autoconfig.anvilcraft.option.lightningStrikeDepth": "Lightning Strike Depth", "text.autoconfig.anvilcraft.option.lightningStrikeDepth.@Tooltip": "Maximum depth a lightning strike can reach", "text.autoconfig.anvilcraft.option.lightningStrikeRadius": "Lightning Strike Radius", @@ -349,5 +352,6 @@ "tooltip.anvilcraft.item.tempering_glass": "Creeper proof, No tools required on collect", "tooltip.anvilcraft.item.topaz": "Containing the power of lightning", "tooltip.anvilcraft.item.transmission_pole": "Build a power grid with a transmission distance of 8", - "tooltip.anvilcraft.jade.power_information": "Power Grid: %d/%d KW" + "tooltip.anvilcraft.jade.power_information": "Power Grid: %d/%d KW", + "tooltip.anvilcraft.ruby_prism.power": "Light level: %d" } \ No newline at end of file diff --git a/fabric/src/generated/resources/assets/anvilcraft/models/item/ruby_laser.json b/fabric/src/generated/resources/assets/anvilcraft/models/item/ruby_laser.json new file mode 100644 index 000000000..d7ef5ec13 --- /dev/null +++ b/fabric/src/generated/resources/assets/anvilcraft/models/item/ruby_laser.json @@ -0,0 +1,3 @@ +{ + "parent": "anvilcraft:block/ruby_laser" +} \ No newline at end of file diff --git a/fabric/src/generated/resources/assets/anvilcraft/models/item/ruby_prism.json b/fabric/src/generated/resources/assets/anvilcraft/models/item/ruby_prism.json new file mode 100644 index 000000000..d42a71d18 --- /dev/null +++ b/fabric/src/generated/resources/assets/anvilcraft/models/item/ruby_prism.json @@ -0,0 +1,3 @@ +{ + "parent": "anvilcraft:block/ruby_prism" +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/misc/ruby_laser.json b/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/misc/ruby_laser.json new file mode 100644 index 000000000..7eee076a5 --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/misc/ruby_laser.json @@ -0,0 +1,74 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_induction_light": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:induction_light" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_royal_steel_ingot": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:royal_steel_ingot" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_ruby_block": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:ruby_block" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_silver_ingot": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:silver_ingot" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "anvilcraft:ruby_laser" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_royal_steel_ingot", + "has_induction_light", + "has_silver_ingot", + "has_ruby_block", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "anvilcraft:ruby_laser" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/misc/ruby_prism.json b/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/misc/ruby_prism.json new file mode 100644 index 000000000..c0fa46a79 --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/misc/ruby_prism.json @@ -0,0 +1,61 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_royal_steel_ingot": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:royal_steel_ingot" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_ruby": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:ruby" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_ruby_block": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:ruby_block" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "anvilcraft:ruby_prism" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_royal_steel_ingot", + "has_ruby_block", + "has_ruby", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "anvilcraft:ruby_prism" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/ruby_laser.json b/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/ruby_laser.json new file mode 100644 index 000000000..cf0899453 --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/ruby_laser.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "anvilcraft:ruby_laser" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "anvilcraft:blocks/ruby_laser" +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/ruby_prism.json b/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/ruby_prism.json new file mode 100644 index 000000000..5dc8fa5a2 --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/ruby_prism.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "anvilcraft:ruby_prism" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "anvilcraft:blocks/ruby_prism" +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/recipes/heating/melt_gem_cauldron.json b/fabric/src/generated/resources/data/anvilcraft/recipes/heating/melt_gem_cauldron.json index da06f9c7e..d98103b07 100644 --- a/fabric/src/generated/resources/data/anvilcraft/recipes/heating/melt_gem_cauldron.json +++ b/fabric/src/generated/resources/data/anvilcraft/recipes/heating/melt_gem_cauldron.json @@ -54,11 +54,10 @@ "min": 1 }, "items": [ - "minecraft:emerald_block", + "anvilcraft:topaz_block", "anvilcraft:sapphire_block", "minecraft:emerald_block", - "anvilcraft:ruby_block", - "anvilcraft:topaz_block" + "anvilcraft:ruby_block" ] }, "offset": [ diff --git a/fabric/src/generated/resources/data/anvilcraft/recipes/ruby_laser.json b/fabric/src/generated/resources/data/anvilcraft/recipes/ruby_laser.json new file mode 100644 index 000000000..cea4766ee --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/recipes/ruby_laser.json @@ -0,0 +1,27 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "item": "anvilcraft:royal_steel_ingot" + }, + "B": { + "item": "anvilcraft:induction_light" + }, + "C": { + "item": "anvilcraft:silver_ingot" + }, + "D": { + "item": "anvilcraft:ruby_block" + } + }, + "pattern": [ + "ACA", + "BDB", + "ACA" + ], + "result": { + "item": "anvilcraft:ruby_laser" + }, + "show_notification": true +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/recipes/ruby_prism.json b/fabric/src/generated/resources/data/anvilcraft/recipes/ruby_prism.json new file mode 100644 index 000000000..1e97f05dd --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/recipes/ruby_prism.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "item": "anvilcraft:royal_steel_ingot" + }, + "B": { + "item": "anvilcraft:ruby_block" + }, + "C": { + "item": "anvilcraft:ruby" + } + }, + "pattern": [ + "ACA", + "CBC", + "AAA" + ], + "result": { + "item": "anvilcraft:ruby_prism" + }, + "show_notification": true +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/tags/blocks/lase_can_pass_though.json b/fabric/src/generated/resources/data/anvilcraft/tags/blocks/lase_can_pass_though.json new file mode 100644 index 000000000..0d2ad4b22 --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/tags/blocks/lase_can_pass_though.json @@ -0,0 +1,10 @@ +{ + "replace": false, + "values": [ + "#c:glass_blocks", + "#c:glass_panes", + "#forge:glass", + "#forge:glass_panes", + "#minecraft:replaceable" + ] +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/c/tags/blocks/glass_blocks.json b/fabric/src/generated/resources/data/c/tags/blocks/glass_blocks.json new file mode 100644 index 000000000..906808f9c --- /dev/null +++ b/fabric/src/generated/resources/data/c/tags/blocks/glass_blocks.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "anvilcraft:tempering_glass" + ] +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/forge/tags/blocks/glass.json b/fabric/src/generated/resources/data/forge/tags/blocks/glass.json new file mode 100644 index 000000000..906808f9c --- /dev/null +++ b/fabric/src/generated/resources/data/forge/tags/blocks/glass.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "anvilcraft:tempering_glass" + ] +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/forge/tags/blocks/glass_blocks.json b/fabric/src/generated/resources/data/forge/tags/blocks/glass_blocks.json new file mode 100644 index 000000000..906808f9c --- /dev/null +++ b/fabric/src/generated/resources/data/forge/tags/blocks/glass_blocks.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "anvilcraft:tempering_glass" + ] +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/fabric/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json index 316744ea7..dc4225c43 100644 --- a/fabric/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json +++ b/fabric/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -139,6 +139,8 @@ "anvilcraft:glowing_netherite_block", "anvilcraft:glowing_tungsten_block", "anvilcraft:incandescent_netherite_block", - "anvilcraft:incandescent_tungsten_block" + "anvilcraft:incandescent_tungsten_block", + "anvilcraft:ruby_prism", + "anvilcraft:ruby_laser" ] } \ No newline at end of file diff --git a/fabric/src/main/java/dev/dubhe/anvilcraft/block/entity/fabric/ChargerBlockEntityImpl.java b/fabric/src/main/java/dev/dubhe/anvilcraft/block/entity/fabric/ChargerBlockEntityImpl.java index 916c7fbf0..51dbfc1cc 100644 --- a/fabric/src/main/java/dev/dubhe/anvilcraft/block/entity/fabric/ChargerBlockEntityImpl.java +++ b/fabric/src/main/java/dev/dubhe/anvilcraft/block/entity/fabric/ChargerBlockEntityImpl.java @@ -2,7 +2,6 @@ import dev.dubhe.anvilcraft.api.depository.fabric.ItemDepositoryHelperImpl; import dev.dubhe.anvilcraft.block.entity.ChargerBlockEntity; -import dev.dubhe.anvilcraft.block.entity.ItemCollectorBlockEntity; import net.fabricmc.fabric.api.transfer.v1.item.ItemStorage; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.entity.BlockEntity; diff --git a/fabric/src/main/java/dev/dubhe/anvilcraft/block/entity/fabric/ItemCollectorBlockEntityImpl.java b/fabric/src/main/java/dev/dubhe/anvilcraft/block/entity/fabric/ItemCollectorBlockEntityImpl.java index 6ed137f6e..da759bfb0 100644 --- a/fabric/src/main/java/dev/dubhe/anvilcraft/block/entity/fabric/ItemCollectorBlockEntityImpl.java +++ b/fabric/src/main/java/dev/dubhe/anvilcraft/block/entity/fabric/ItemCollectorBlockEntityImpl.java @@ -1,7 +1,6 @@ package dev.dubhe.anvilcraft.block.entity.fabric; import dev.dubhe.anvilcraft.api.depository.fabric.ItemDepositoryHelperImpl; -import dev.dubhe.anvilcraft.block.entity.AutoCrafterBlockEntity; import dev.dubhe.anvilcraft.block.entity.ItemCollectorBlockEntity; import net.fabricmc.fabric.api.transfer.v1.item.ItemStorage; import net.minecraft.core.BlockPos; diff --git a/fabric/src/main/java/dev/dubhe/anvilcraft/client/fabric/AnvilCraftFabricClient.java b/fabric/src/main/java/dev/dubhe/anvilcraft/client/fabric/AnvilCraftFabricClient.java index 7e58226e6..f37aa42df 100644 --- a/fabric/src/main/java/dev/dubhe/anvilcraft/client/fabric/AnvilCraftFabricClient.java +++ b/fabric/src/main/java/dev/dubhe/anvilcraft/client/fabric/AnvilCraftFabricClient.java @@ -25,6 +25,8 @@ public void onInitializeClient() { BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.PIEZOELECTRIC_CRYSTAL.get(), RenderType.translucent()); BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.BLOCK_PLACER.get(), RenderType.cutout()); BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.BLOCK_DEVOURER.get(), RenderType.cutout()); + BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.RUBY_PRISM.get(), RenderType.translucent()); + BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.RUBY_LASER.get(), RenderType.translucent()); WorldRenderEvents.AFTER_ENTITIES.register(context -> { if (IBlockHighlightUtil.SUBCHUNKS.isEmpty()) return; MultiBufferSource consumers = context.consumers(); diff --git a/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerBlockEntityEventListener.java b/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerBlockEntityEventListener.java index aff4c3af6..c47a9bbf1 100644 --- a/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerBlockEntityEventListener.java +++ b/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerBlockEntityEventListener.java @@ -34,6 +34,7 @@ private static void onUnload(BlockEntity entity, ServerLevel level) { } if (entity instanceof OverseerBlockEntity overseerBlockEntity) { LevelLoadManager.unregister(overseerBlockEntity.getBlockPos(), level); + return; } } } diff --git a/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerWorldEventListener.java b/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerWorldEventListener.java index 8151ec9db..457fb098b 100644 --- a/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerWorldEventListener.java +++ b/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerWorldEventListener.java @@ -4,7 +4,6 @@ import dev.dubhe.anvilcraft.api.entity.fakeplayer.fabric.AnvilCraftBlockPlacerFakePlayer; import dev.dubhe.anvilcraft.api.entity.player.AnvilCraftBlockPlacer; import dev.dubhe.anvilcraft.api.world.load.LevelLoadManager; -import dev.dubhe.anvilcraft.client.renderer.PowerGridRenderer; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; @@ -26,8 +25,6 @@ private static void onload(MinecraftServer server, Level level) { private static void onUnload(MinecraftServer server, Level level) { ChargeCollectorManager.cleanMap(); - if (level instanceof ServerLevel serverLevel) { - LevelLoadManager.removeAll(serverLevel); - } + if (level instanceof ServerLevel serverLevel) LevelLoadManager.removeAll(serverLevel); } } diff --git a/forge/src/generated/resources/assets/anvilcraft/lang/en_ud.json b/forge/src/generated/resources/assets/anvilcraft/lang/en_ud.json index 17ce726e6..597c9696e 100644 --- a/forge/src/generated/resources/assets/anvilcraft/lang/en_ud.json +++ b/forge/src/generated/resources/assets/anvilcraft/lang/en_ud.json @@ -134,6 +134,8 @@ "block.anvilcraft.royal_smithing_table": "ǝןqɐ⟘ buıɥʇıɯS ןɐʎoᴚ", "block.anvilcraft.royal_steel_block": "ʞɔoןᗺ ןǝǝʇS ןɐʎoᴚ", "block.anvilcraft.ruby_block": "ʞɔoןᗺ ʎqnᴚ", + "block.anvilcraft.ruby_laser": "ɹǝsɐꞀ ʎqnᴚ", + "block.anvilcraft.ruby_prism": "ɯsıɹԀ ʎqnᴚ", "block.anvilcraft.sapphire_block": "ʞɔoןᗺ ǝɹıɥddɐS", "block.anvilcraft.silver_block": "ʞɔoןᗺ ɹǝʌןıS", "block.anvilcraft.simple_chute": "ǝʇnɥƆ ǝןdɯıS", @@ -278,6 +280,7 @@ "text.autoconfig.anvilcraft.option.geodeInterval.@Tooltip": "ǝpoǝb ǝɥʇ ɟo ןɐʌɹǝʇuı ɥɔɹɐǝs ǝɥ⟘", "text.autoconfig.anvilcraft.option.geodeRadius": "snıpɐᴚ ɥɔɹɐǝS ɯnɯıxɐW ǝpoǝ⅁", "text.autoconfig.anvilcraft.option.geodeRadius.@Tooltip": "ǝpoǝb ǝɥʇ ɟo snıpɐɹ ɥɔɹɐǝs ɯnɯıxɐɯ ǝɥ⟘", + "text.autoconfig.anvilcraft.option.isLaserDoImpactChecking": "buıʞɔǝɥƆ ʇɔɐdɯI oᗡ ɹǝsɐꞀ sI", "text.autoconfig.anvilcraft.option.lightningStrikeDepth": "ɥʇdǝᗡ ǝʞıɹʇS buıuʇɥbıꞀ", "text.autoconfig.anvilcraft.option.lightningStrikeDepth.@Tooltip": "ɥɔɐǝɹ uɐɔ ǝʞıɹʇs buıuʇɥbıן ɐ ɥʇdǝp ɯnɯıxɐW", "text.autoconfig.anvilcraft.option.lightningStrikeRadius": "snıpɐᴚ ǝʞıɹʇS buıuʇɥbıꞀ", @@ -349,5 +352,6 @@ "tooltip.anvilcraft.item.tempering_glass": "ʇɔǝןןoɔ uo pǝɹınbǝɹ sןooʇ oN 'ɟooɹd ɹǝdǝǝɹƆ", "tooltip.anvilcraft.item.topaz": "buıuʇɥbıן ɟo ɹǝʍod ǝɥʇ buıuıɐʇuoƆ", "tooltip.anvilcraft.item.transmission_pole": "8 ɟo ǝɔuɐʇsıp uoıssıɯsuɐɹʇ ɐ ɥʇıʍ pıɹb ɹǝʍod ɐ pןınᗺ", - "tooltip.anvilcraft.jade.power_information": "Mʞ %d/%d :pıɹ⅁ ɹǝʍoԀ" + "tooltip.anvilcraft.jade.power_information": "Mʞ %d/%d :pıɹ⅁ ɹǝʍoԀ", + "tooltip.anvilcraft.ruby_prism.power": "%d :ןǝʌǝן ʇɥbıꞀ" } \ No newline at end of file diff --git a/forge/src/generated/resources/assets/anvilcraft/lang/en_us.json b/forge/src/generated/resources/assets/anvilcraft/lang/en_us.json index b1dfafa07..f29268c1d 100644 --- a/forge/src/generated/resources/assets/anvilcraft/lang/en_us.json +++ b/forge/src/generated/resources/assets/anvilcraft/lang/en_us.json @@ -134,6 +134,8 @@ "block.anvilcraft.royal_smithing_table": "Royal Smithing Table", "block.anvilcraft.royal_steel_block": "Royal Steel Block", "block.anvilcraft.ruby_block": "Ruby Block", + "block.anvilcraft.ruby_laser": "Ruby Laser", + "block.anvilcraft.ruby_prism": "Ruby Prism", "block.anvilcraft.sapphire_block": "Sapphire Block", "block.anvilcraft.silver_block": "Silver Block", "block.anvilcraft.simple_chute": "Simple Chute", @@ -278,6 +280,7 @@ "text.autoconfig.anvilcraft.option.geodeInterval.@Tooltip": "The search interval of the geode", "text.autoconfig.anvilcraft.option.geodeRadius": "Geode Maximum Search Radius", "text.autoconfig.anvilcraft.option.geodeRadius.@Tooltip": "The maximum search radius of the geode", + "text.autoconfig.anvilcraft.option.isLaserDoImpactChecking": "Is Laser Do Impact Checking", "text.autoconfig.anvilcraft.option.lightningStrikeDepth": "Lightning Strike Depth", "text.autoconfig.anvilcraft.option.lightningStrikeDepth.@Tooltip": "Maximum depth a lightning strike can reach", "text.autoconfig.anvilcraft.option.lightningStrikeRadius": "Lightning Strike Radius", @@ -349,5 +352,6 @@ "tooltip.anvilcraft.item.tempering_glass": "Creeper proof, No tools required on collect", "tooltip.anvilcraft.item.topaz": "Containing the power of lightning", "tooltip.anvilcraft.item.transmission_pole": "Build a power grid with a transmission distance of 8", - "tooltip.anvilcraft.jade.power_information": "Power Grid: %d/%d KW" + "tooltip.anvilcraft.jade.power_information": "Power Grid: %d/%d KW", + "tooltip.anvilcraft.ruby_prism.power": "Light level: %d" } \ No newline at end of file diff --git a/forge/src/generated/resources/assets/anvilcraft/models/item/ruby_laser.json b/forge/src/generated/resources/assets/anvilcraft/models/item/ruby_laser.json new file mode 100644 index 000000000..d7ef5ec13 --- /dev/null +++ b/forge/src/generated/resources/assets/anvilcraft/models/item/ruby_laser.json @@ -0,0 +1,3 @@ +{ + "parent": "anvilcraft:block/ruby_laser" +} \ No newline at end of file diff --git a/forge/src/generated/resources/assets/anvilcraft/models/item/ruby_prism.json b/forge/src/generated/resources/assets/anvilcraft/models/item/ruby_prism.json new file mode 100644 index 000000000..d42a71d18 --- /dev/null +++ b/forge/src/generated/resources/assets/anvilcraft/models/item/ruby_prism.json @@ -0,0 +1,3 @@ +{ + "parent": "anvilcraft:block/ruby_prism" +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/advancements/recipes/misc/ruby_laser.json b/forge/src/generated/resources/data/anvilcraft/advancements/recipes/misc/ruby_laser.json new file mode 100644 index 000000000..7eee076a5 --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/advancements/recipes/misc/ruby_laser.json @@ -0,0 +1,74 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_induction_light": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:induction_light" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_royal_steel_ingot": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:royal_steel_ingot" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_ruby_block": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:ruby_block" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_silver_ingot": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:silver_ingot" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "anvilcraft:ruby_laser" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_royal_steel_ingot", + "has_induction_light", + "has_silver_ingot", + "has_ruby_block", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "anvilcraft:ruby_laser" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/advancements/recipes/misc/ruby_prism.json b/forge/src/generated/resources/data/anvilcraft/advancements/recipes/misc/ruby_prism.json new file mode 100644 index 000000000..c0fa46a79 --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/advancements/recipes/misc/ruby_prism.json @@ -0,0 +1,61 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_royal_steel_ingot": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:royal_steel_ingot" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_ruby": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:ruby" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_ruby_block": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:ruby_block" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "anvilcraft:ruby_prism" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_royal_steel_ingot", + "has_ruby_block", + "has_ruby", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "anvilcraft:ruby_prism" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/ruby_laser.json b/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/ruby_laser.json new file mode 100644 index 000000000..cf0899453 --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/ruby_laser.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "anvilcraft:ruby_laser" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "anvilcraft:blocks/ruby_laser" +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/ruby_prism.json b/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/ruby_prism.json new file mode 100644 index 000000000..5dc8fa5a2 --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/ruby_prism.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "anvilcraft:ruby_prism" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "anvilcraft:blocks/ruby_prism" +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/recipes/heating/melt_gem_cauldron.json b/forge/src/generated/resources/data/anvilcraft/recipes/heating/melt_gem_cauldron.json index da06f9c7e..d98103b07 100644 --- a/forge/src/generated/resources/data/anvilcraft/recipes/heating/melt_gem_cauldron.json +++ b/forge/src/generated/resources/data/anvilcraft/recipes/heating/melt_gem_cauldron.json @@ -54,11 +54,10 @@ "min": 1 }, "items": [ - "minecraft:emerald_block", + "anvilcraft:topaz_block", "anvilcraft:sapphire_block", "minecraft:emerald_block", - "anvilcraft:ruby_block", - "anvilcraft:topaz_block" + "anvilcraft:ruby_block" ] }, "offset": [ diff --git a/forge/src/generated/resources/data/anvilcraft/recipes/ruby_laser.json b/forge/src/generated/resources/data/anvilcraft/recipes/ruby_laser.json new file mode 100644 index 000000000..cea4766ee --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/recipes/ruby_laser.json @@ -0,0 +1,27 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "item": "anvilcraft:royal_steel_ingot" + }, + "B": { + "item": "anvilcraft:induction_light" + }, + "C": { + "item": "anvilcraft:silver_ingot" + }, + "D": { + "item": "anvilcraft:ruby_block" + } + }, + "pattern": [ + "ACA", + "BDB", + "ACA" + ], + "result": { + "item": "anvilcraft:ruby_laser" + }, + "show_notification": true +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/recipes/ruby_prism.json b/forge/src/generated/resources/data/anvilcraft/recipes/ruby_prism.json new file mode 100644 index 000000000..1e97f05dd --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/recipes/ruby_prism.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "item": "anvilcraft:royal_steel_ingot" + }, + "B": { + "item": "anvilcraft:ruby_block" + }, + "C": { + "item": "anvilcraft:ruby" + } + }, + "pattern": [ + "ACA", + "CBC", + "AAA" + ], + "result": { + "item": "anvilcraft:ruby_prism" + }, + "show_notification": true +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/tags/blocks/lase_can_pass_though.json b/forge/src/generated/resources/data/anvilcraft/tags/blocks/lase_can_pass_though.json new file mode 100644 index 000000000..0d2ad4b22 --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/tags/blocks/lase_can_pass_though.json @@ -0,0 +1,10 @@ +{ + "replace": false, + "values": [ + "#c:glass_blocks", + "#c:glass_panes", + "#forge:glass", + "#forge:glass_panes", + "#minecraft:replaceable" + ] +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/c/tags/blocks/glass_blocks.json b/forge/src/generated/resources/data/c/tags/blocks/glass_blocks.json new file mode 100644 index 000000000..906808f9c --- /dev/null +++ b/forge/src/generated/resources/data/c/tags/blocks/glass_blocks.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "anvilcraft:tempering_glass" + ] +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/forge/tags/blocks/glass.json b/forge/src/generated/resources/data/forge/tags/blocks/glass.json new file mode 100644 index 000000000..906808f9c --- /dev/null +++ b/forge/src/generated/resources/data/forge/tags/blocks/glass.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "anvilcraft:tempering_glass" + ] +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/forge/tags/blocks/glass_blocks.json b/forge/src/generated/resources/data/forge/tags/blocks/glass_blocks.json new file mode 100644 index 000000000..906808f9c --- /dev/null +++ b/forge/src/generated/resources/data/forge/tags/blocks/glass_blocks.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "anvilcraft:tempering_glass" + ] +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/forge/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json index 316744ea7..dc4225c43 100644 --- a/forge/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json +++ b/forge/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -139,6 +139,8 @@ "anvilcraft:glowing_netherite_block", "anvilcraft:glowing_tungsten_block", "anvilcraft:incandescent_netherite_block", - "anvilcraft:incandescent_tungsten_block" + "anvilcraft:incandescent_tungsten_block", + "anvilcraft:ruby_prism", + "anvilcraft:ruby_laser" ] } \ No newline at end of file diff --git a/forge/src/main/java/dev/dubhe/anvilcraft/block/entity/forge/ChargerBlockEntityImpl.java b/forge/src/main/java/dev/dubhe/anvilcraft/block/entity/forge/ChargerBlockEntityImpl.java index baa8344af..98313ca94 100644 --- a/forge/src/main/java/dev/dubhe/anvilcraft/block/entity/forge/ChargerBlockEntityImpl.java +++ b/forge/src/main/java/dev/dubhe/anvilcraft/block/entity/forge/ChargerBlockEntityImpl.java @@ -2,7 +2,6 @@ import dev.dubhe.anvilcraft.api.depository.forge.ItemDepositoryHelperImpl; import dev.dubhe.anvilcraft.block.entity.ChargerBlockEntity; -import dev.dubhe.anvilcraft.block.entity.ItemCollectorBlockEntity; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.block.entity.BlockEntity; diff --git a/forge/src/main/java/dev/dubhe/anvilcraft/block/entity/forge/ItemCollectorBlockEntityImpl.java b/forge/src/main/java/dev/dubhe/anvilcraft/block/entity/forge/ItemCollectorBlockEntityImpl.java index baf1aac07..fe838b72e 100644 --- a/forge/src/main/java/dev/dubhe/anvilcraft/block/entity/forge/ItemCollectorBlockEntityImpl.java +++ b/forge/src/main/java/dev/dubhe/anvilcraft/block/entity/forge/ItemCollectorBlockEntityImpl.java @@ -1,7 +1,6 @@ package dev.dubhe.anvilcraft.block.entity.forge; import dev.dubhe.anvilcraft.api.depository.forge.ItemDepositoryHelperImpl; -import dev.dubhe.anvilcraft.block.entity.AutoCrafterBlockEntity; import dev.dubhe.anvilcraft.block.entity.ItemCollectorBlockEntity; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction;