diff --git a/.gitignore b/.gitignore index e6f1a16ec..8cd1abd2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # User-specific stuff .idea/ +!.idea/icon.svg *.iml *.ipr diff --git a/.idea/icon.svg b/.idea/icon.svg new file mode 100644 index 000000000..6c3268648 --- /dev/null +++ b/.idea/icon.svg @@ -0,0 +1,47 @@ + + + + diff --git a/common/src/main/java/dev/dubhe/anvilcraft/AnvilCraft.java b/common/src/main/java/dev/dubhe/anvilcraft/AnvilCraft.java index f4a9f2165..21aec145b 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/AnvilCraft.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/AnvilCraft.java @@ -52,7 +52,7 @@ public static void init() { REGISTRATE.registerRegistrate(); } - public static @NotNull ResourceLocation of(String id) { - return new ResourceLocation(MOD_ID, id); + public static @NotNull ResourceLocation of(String path) { + return new ResourceLocation(MOD_ID, path); } } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerComponent.java b/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerComponent.java new file mode 100644 index 000000000..8855795cd --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerComponent.java @@ -0,0 +1,44 @@ +package dev.dubhe.anvilcraft.api.power; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * 电力元件 + */ +@SuppressWarnings("unused") +public interface IPowerComponent { + /** + * @return 元件位置 + */ + @NotNull + BlockPos getPos(); + + default VoxelShape getRange() { + return Shapes.block(); + } + + /** + * 设置电网 + * + * @param grid 电网 + */ + void setGrid(@Nullable PowerGrid grid); + + /** + * 获取电网 + * + * @return 电网 + */ + @Nullable + PowerGrid getGrid(); + + /** + * @return 元件类型 + */ + @NotNull + PowerComponentType getComponentType(); +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerConsumer.java b/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerConsumer.java new file mode 100644 index 000000000..bd7e2bb78 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerConsumer.java @@ -0,0 +1,20 @@ +package dev.dubhe.anvilcraft.api.power; + +import org.jetbrains.annotations.NotNull; + +/** + * 用电 + */ +public interface IPowerConsumer extends IPowerComponent { + /** + * @return 输入功率 + */ + default int getInputPower() { + return 0; + } + + @Override + default @NotNull PowerComponentType getComponentType() { + return PowerComponentType.CONSUMER; + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerProducer.java b/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerProducer.java new file mode 100644 index 000000000..f25774d2a --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerProducer.java @@ -0,0 +1,20 @@ +package dev.dubhe.anvilcraft.api.power; + +import org.jetbrains.annotations.NotNull; + +/** + * 发电 + */ +public interface IPowerProducer extends IPowerComponent { + /** + * @return 输出功率 + */ + default int getOutputPower() { + return 0; + } + + @Override + default @NotNull PowerComponentType getComponentType() { + return PowerComponentType.PRODUCER; + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerStorage.java b/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerStorage.java new file mode 100644 index 000000000..e36973cf7 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerStorage.java @@ -0,0 +1,29 @@ +package dev.dubhe.anvilcraft.api.power; + +import org.jetbrains.annotations.NotNull; + +/** + * 储电 + */ +public interface IPowerStorage extends IPowerProducer, IPowerConsumer { + /** + * 输入电量 + * + * @param power 输入值 + * @return 无法输入的值 + */ + int insert(int power); + + /** + * 获取电量 + * + * @param power 想要获取的值 + * @return 实际获取的值 + */ + int extract(int power); + + @Override + default @NotNull PowerComponentType getComponentType() { + return PowerComponentType.STORAGE; + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerTransmitter.java b/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerTransmitter.java new file mode 100644 index 000000000..0a1c7a67e --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/api/power/IPowerTransmitter.java @@ -0,0 +1,22 @@ +package dev.dubhe.anvilcraft.api.power; + +import dev.dubhe.anvilcraft.AnvilCraft; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; + +/** + * 电力中继器 + */ +public interface IPowerTransmitter extends IPowerComponent { + @Override + default VoxelShape getRange() { + int range = AnvilCraft.config.powerTransmitterRange; + return Shapes.box(-range, -range, -range, range + 1, range + 1, range + 1); + } + + @Override + default @NotNull PowerComponentType getComponentType() { + return PowerComponentType.TRANSMITTER; + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/api/power/PowerComponentType.java b/common/src/main/java/dev/dubhe/anvilcraft/api/power/PowerComponentType.java new file mode 100644 index 000000000..501475f5e --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/api/power/PowerComponentType.java @@ -0,0 +1,12 @@ +package dev.dubhe.anvilcraft.api.power; + +/** + * 电力元件类型 + */ +public enum PowerComponentType { + INVALID, + PRODUCER, + CONSUMER, + STORAGE, + TRANSMITTER +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java b/common/src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java new file mode 100644 index 000000000..ee4803afd --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java @@ -0,0 +1,279 @@ +package dev.dubhe.anvilcraft.api.power; + +import dev.dubhe.anvilcraft.AnvilCraft; +import lombok.Getter; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.shapes.BooleanOp; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.Set; + +/** + * 电网 + */ +@SuppressWarnings("unused") +public class PowerGrid { + public static boolean isServerClosing = false; + @Getter + private static Set gridSetClient = Collections.synchronizedSet(new HashSet<>()); + public static final Set GRID_SET = new HashSet<>(); + public static final int GRID_TICK = 40; + public static int cooldown = 0; + @Getter + private int generate = 0; // 发电功率 + @Getter + private int consume = 0; // 耗电功率 + private final Set producers = new HashSet<>(); // 发电机 + private final Set consumers = new HashSet<>(); // 用电器 + private final Set storages = new HashSet<>(); // 储电 + private final Set transmitters = new HashSet<>(); // 中继 + @Getter + private VoxelShape range = null; + @Getter + private BlockPos pos = null; + + /** + * @return 获取电网中的元件数量 + */ + public int getComponentCount() { + return this.transmitters.size() + this.producers.size() + this.consumers.size() + this.storages.size(); + } + + /** + * @return 该电网是否为空电网 + */ + public boolean isEmpty() { + return this.getComponentCount() <= 0; + } + + /** + * 总电力刻 + */ + public static void tickGrid() { + if (cooldown > 0) { + cooldown--; + return; + } + Iterator iterator = PowerGrid.GRID_SET.iterator(); + while (iterator.hasNext()) { + PowerGrid grid = iterator.next(); + if (grid.isEmpty()) iterator.remove(); + grid.tick(); + } + cooldown = GRID_TICK; + gridSetClient = Set.copyOf(GRID_SET); + } + + /** + * 电力刻 + */ + protected void tick() { + if (this.flush()) return; + if (this.isWork()) { + int remainder = this.generate - this.consume; + for (IPowerStorage storage : storages) { + if (checkRemove(storage)) return; + remainder = storage.insert(remainder); + if (remainder <= 0) break; + } + } else { + int need = this.consume - this.generate; + Set storages = new HashSet<>(); + for (IPowerStorage storage : this.storages) { + need -= storage.getOutputPower(); + storages.add(storage); + if (need <= 0) break; + } + if (need > 0) return; + for (IPowerStorage storage : storages) { + this.generate += storage.extract(this.consume - this.generate); + } + } + } + + private boolean checkRemove(IPowerComponent component) { + if (component instanceof BlockEntity entity && entity.isRemoved()) { + PowerGrid.removeComponent(component); + return true; + } + return false; + } + + private boolean flush() { + this.generate = 0; + this.consume = 0; + for (IPowerTransmitter transmitter : transmitters) { + if (checkRemove(transmitter)) return true; + } + for (IPowerProducer producer : this.producers) { + if (checkRemove(producer)) return true; + this.generate += producer.getOutputPower(); + } + for (IPowerConsumer consumer : this.consumers) { + if (checkRemove(consumer)) return true; + this.consume += consumer.getInputPower(); + } + return false; + } + + public boolean isWork() { + return this.generate >= this.consume; + } + + /** + * 增加电力元件 + * + * @param components 元件 + */ + public void add(IPowerComponent @NotNull ... components) { + for (IPowerComponent component : components) { + if (component.getComponentType() == PowerComponentType.INVALID) continue; + if (component instanceof IPowerStorage storage) { + this.storages.add(storage); + continue; + } + if (component instanceof IPowerProducer producer) { + this.producers.add(producer); + } + if (component instanceof IPowerConsumer consumer) { + this.consumers.add(consumer); + } + if (component instanceof IPowerTransmitter transmitter) { + this.transmitters.add(transmitter); + } + component.setGrid(this); + this.addRange(component); + } + this.flush(); + } + + private void addRange(IPowerComponent component) { + if (this.range == null) { + this.range = component.getRange(); + this.pos = component.getPos(); + return; + } + BlockPos center = this.pos; + BlockPos vec3 = component.getPos(); + VoxelShape range = component.getRange().move( + vec3.getX() - center.getX(), + vec3.getY() - center.getY(), + vec3.getZ() - center.getZ() + ); + this.range = Shapes.join(this.range, range, BooleanOp.OR); + } + + /** + * 移除除电网元件 + * + * @param components 元件 + */ + public static void removeComponent(IPowerComponent @NotNull ... components) { + try { + if (PowerGrid.isServerClosing) return; + for (IPowerComponent component : components) { + PowerGrid grid = component.getGrid(); + if (grid == null) return; + grid.remove(component); + } + } catch (Exception e) { + AnvilCraft.LOGGER.error(e.getMessage(), e); + } + } + + /** + * 移除电力元件 + * + * @param components 电力元件 + */ + public void remove(IPowerComponent @NotNull ... components) { + Set set = new LinkedHashSet<>(); + this.transmitters.stream().filter(this::clearGrid).forEach(set::add); + this.transmitters.clear(); + this.storages.stream().filter(this::clearGrid).forEach(set::add); + this.storages.clear(); + this.producers.stream().filter(this::clearGrid).forEach(set::add); + this.producers.clear(); + this.consumers.stream().filter(this::clearGrid).forEach(set::add); + this.consumers.clear(); + for (IPowerComponent component : components) { + set.remove(component); + } + PowerGrid.GRID_SET.remove(this); + PowerGrid.addComponent(set.toArray(IPowerComponent[]::new)); + } + + private boolean clearGrid(@NotNull IPowerComponent component) { + component.setGrid(null); + return true; + } + + /** + * 将另一个电网合并至当前电网 + * + * @param grid 电网 + */ + public void merge(@NotNull PowerGrid grid) { + grid.producers.forEach(producer -> producer.setGrid(this)); + this.producers.addAll(grid.producers); + grid.consumers.forEach(producer -> producer.setGrid(this)); + this.consumers.addAll(grid.consumers); + grid.storages.forEach(producer -> producer.setGrid(this)); + this.storages.addAll(grid.storages); + grid.transmitters.forEach(producer -> producer.setGrid(this)); + this.transmitters.addAll(grid.transmitters); + } + + /** + * @param component 元件 + * @return 元件是否在电网范围内 + */ + public boolean isInRange(@NotNull IPowerComponent component) { + BlockPos vec3 = component.getPos().subtract(this.getPos()); + VoxelShape range = Shapes.join( + this.range, + component.getRange().move(vec3.getX(), vec3.getY(), vec3.getZ()), + BooleanOp.AND + ); + return !range.isEmpty(); + } + + /** + * 增加电力元件 + * + * @param components 元件 + */ + public static void addComponent(IPowerComponent @NotNull ... components) { + for (IPowerComponent component : components) { + if (component.getComponentType() == PowerComponentType.INVALID) continue; + PowerGrid grid = null; + Iterator iterator = PowerGrid.GRID_SET.iterator(); + while (iterator.hasNext()) { + PowerGrid grid1 = iterator.next(); + if (!grid1.isInRange(component)) continue; + if (grid == null) grid = grid1; + else { + grid.merge(grid1); + iterator.remove(); + } + } + if (grid == null) grid = new PowerGrid(); + grid.add(component); + PowerGrid.GRID_SET.add(grid); + } + } + + /** + * 清空电网 + */ + public static void clear() { + PowerGrid.GRID_SET.clear(); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/ChuteBlock.java b/common/src/main/java/dev/dubhe/anvilcraft/block/ChuteBlock.java index f444086bf..036942fec 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/block/ChuteBlock.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/ChuteBlock.java @@ -133,7 +133,7 @@ public void neighborChanged( } if (!neighborPos.equals(pos.relative(state.getValue(FACING)))) return; BlockState blockState = level.getBlockState(neighborPos); - if (blockState.is(ModBlocks.CHUTE.get())) return; + if (!blockState.is(ModBlocks.CHUTE.get())) return; if (hasChuteFacing(level, neighborPos)) { BlockState newState = ModBlocks.SIMPLE_CHUTE.getDefaultState(); newState = newState.setValue(SimpleChuteBlock.FACING, blockState.getValue(FACING)) diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/CorruptedBeaconBlock.java b/common/src/main/java/dev/dubhe/anvilcraft/block/CorruptedBeaconBlock.java index a721dc2c6..d1a1b9fd9 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/block/CorruptedBeaconBlock.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/CorruptedBeaconBlock.java @@ -35,7 +35,7 @@ public CorruptedBeaconBlock(Properties properties) { @Override public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { - return CorruptedBeaconBlockEntity.createBlockEntity(ModBlockEntities.CORRUPTED_BEACON.get(), pos, state); + return new CorruptedBeaconBlockEntity(pos, state); } @Override diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/CreativeDynamoBlock.java b/common/src/main/java/dev/dubhe/anvilcraft/block/CreativeDynamoBlock.java new file mode 100644 index 000000000..26d3e833a --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/CreativeDynamoBlock.java @@ -0,0 +1,72 @@ +package dev.dubhe.anvilcraft.block; + +import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable; +import dev.dubhe.anvilcraft.block.entity.CreativeDynamoBlockEntity; +import dev.dubhe.anvilcraft.init.ModMenuTypes; +import dev.dubhe.anvilcraft.network.SliderInitPack; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +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.RenderShape; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.annotation.Nonnull; + +public class CreativeDynamoBlock extends BaseEntityBlock implements IHammerRemovable { + public static final VoxelShape AABB = Block.box(0, 0, 0, 16, 4, 16); + + public CreativeDynamoBlock(Properties properties) { + super(properties); + } + + @Override + @SuppressWarnings({"deprecation", "UnreachableCode"}) + public @NotNull InteractionResult use( + @NotNull BlockState state, @NotNull Level level, + @NotNull BlockPos pos, @NotNull Player player, + @NotNull InteractionHand hand, @NotNull BlockHitResult hit + ) { + if (level.isClientSide) { + return InteractionResult.SUCCESS; + } + if ( + level.getBlockEntity(pos) instanceof CreativeDynamoBlockEntity entity + && player instanceof ServerPlayer serverPlayer + ) { + ModMenuTypes.open(serverPlayer, entity, pos); + new SliderInitPack(entity.getPower(), -8192, 8192).send(serverPlayer); + } + return InteractionResult.SUCCESS; + } + + @Nullable + @Override + public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { + return new CreativeDynamoBlockEntity(pos, state); + } + + @Override + public @Nonnull RenderShape getRenderShape(@Nonnull BlockState state) { + return RenderShape.MODEL; + } + + @Override + @SuppressWarnings("deprecation") + public @NotNull VoxelShape getShape( + @NotNull BlockState state, @NotNull BlockGetter level, @NotNull BlockPos pos, @NotNull CollisionContext context + ) { + return CreativeDynamoBlock.AABB; + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/HeaterBlock.java b/common/src/main/java/dev/dubhe/anvilcraft/block/HeaterBlock.java new file mode 100644 index 000000000..73eea8452 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/HeaterBlock.java @@ -0,0 +1,63 @@ +package dev.dubhe.anvilcraft.block; + +import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable; +import dev.dubhe.anvilcraft.block.entity.HeaterBlockEntity; +import dev.dubhe.anvilcraft.init.ModBlockEntities; +import net.minecraft.core.BlockPos; +import net.minecraft.world.item.context.BlockPlaceContext; +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.RedstoneTorchBlock; +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 org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.annotation.Nonnull; + +public class HeaterBlock extends BaseEntityBlock implements IHammerRemovable { + public static final BooleanProperty LIT = RedstoneTorchBlock.LIT; + + public HeaterBlock(Properties properties) { + super(properties); + this.registerDefaultState(this.stateDefinition.any().setValue(LIT, false)); + } + + @Override + @Nullable + public BlockState getStateForPlacement(@NotNull BlockPlaceContext context) { + return this.defaultBlockState().setValue(LIT, false); + } + + @Nullable + @Override + public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { + return new HeaterBlockEntity(pos, state); + } + + @Override + protected void createBlockStateDefinition(@NotNull StateDefinition.Builder builder) { + builder.add(LIT); + } + + @Override + public @Nonnull RenderShape getRenderShape(@Nonnull BlockState state) { + return RenderShape.MODEL; + } + + @Nullable + @Override + public BlockEntityTicker getTicker( + @NotNull Level level, @NotNull BlockState state, @NotNull BlockEntityType type + ) { + if (level.isClientSide) return null; + return createTickerHelper(type, ModBlockEntities.HEATER.get(), + (level1, pos, state1, entity) -> entity.tick(level1, pos)); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/SimpleChuteBlock.java b/common/src/main/java/dev/dubhe/anvilcraft/block/SimpleChuteBlock.java index 22478a3a6..b982d6924 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/block/SimpleChuteBlock.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/SimpleChuteBlock.java @@ -102,7 +102,7 @@ public void neighborChanged( } if (!neighborPos.equals(pos.relative(state.getValue(FACING)))) return; BlockState blockState = level.getBlockState(neighborPos); - if (blockState.is(ModBlocks.CHUTE.get())) return; + if (!blockState.is(ModBlocks.CHUTE.get())) return; if (ChuteBlock.hasChuteFacing(level, neighborPos)) { BlockState newState = ModBlocks.SIMPLE_CHUTE.getDefaultState(); newState = newState.setValue(SimpleChuteBlock.FACING, blockState.getValue(FACING)) diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/TransmissionPoleBlock.java b/common/src/main/java/dev/dubhe/anvilcraft/block/TransmissionPoleBlock.java new file mode 100644 index 000000000..8cd1c496c --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/TransmissionPoleBlock.java @@ -0,0 +1,143 @@ +package dev.dubhe.anvilcraft.block; + +import dev.dubhe.anvilcraft.api.hammer.IHammerRemovable; +import dev.dubhe.anvilcraft.block.entity.TransmissionPoleBlockEntity; +import dev.dubhe.anvilcraft.block.state.Half; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.BaseEntityBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.RenderShape; +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.EnumProperty; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.annotation.Nonnull; + +public class TransmissionPoleBlock extends BaseEntityBlock implements IHammerRemovable { + public static final EnumProperty HALF = EnumProperty.create("half", Half.class); + + public TransmissionPoleBlock(Properties properties) { + super(properties); + this.registerDefaultState(this.stateDefinition.any().setValue(HALF, Half.BOTTOM)); + } + + @Override + @Nullable + public BlockState getStateForPlacement(@NotNull BlockPlaceContext context) { + return this.defaultBlockState().setValue(HALF, Half.BOTTOM); + } + + @Override + protected void createBlockStateDefinition(@NotNull StateDefinition.Builder builder) { + builder.add(HALF); + } + + @Override + public @Nonnull RenderShape getRenderShape(@Nonnull BlockState state) { + return RenderShape.MODEL; + } + + @Override + public void setPlacedBy( + @NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, + LivingEntity placer, @NotNull ItemStack stack + ) { + BlockPos above = pos.above(); + level.setBlockAndUpdate(above, state.setValue(HALF, Half.MID)); + above = above.above(); + level.setBlockAndUpdate(above, state.setValue(HALF, Half.TOP)); + } + + @Override + public void playerWillDestroy( + @NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull Player player + ) { + if (!level.isClientSide) { + TransmissionPoleBlock.preventDropFromOtherPart(level, pos, state, player); + } + super.playerWillDestroy(level, pos, state, player); + } + + private static void preventDropFromOtherPart( + Level level, BlockPos pos, @NotNull BlockState state, Player player + ) { + BlockPos blockPos; + BlockState blockState; + BlockPos blockPos1; + BlockState blockState1; + Half half = state.getValue(HALF); + block: + if ( + half == Half.TOP + && (blockState = level.getBlockState(blockPos = pos.below())).is(state.getBlock()) + && blockState.getValue(HALF) == Half.MID + && (blockState1 = level.getBlockState(blockPos1 = blockPos.below())).is(state.getBlock()) + && blockState1.getValue(HALF) == Half.BOTTOM + ) { + breakOtherPart(level, blockPos, blockState, blockPos1, blockState1, player); + } else if ( + half == Half.MID + && (blockState = level.getBlockState(blockPos = pos.above())).is(state.getBlock()) + && blockState.getValue(HALF) == Half.TOP + && (blockState1 = level.getBlockState(blockPos1 = pos.below())).is(state.getBlock()) + && blockState1.getValue(HALF) == Half.BOTTOM + ) { + breakOtherPart(level, blockPos, blockState, blockPos1, blockState1, player); + } else if ( + half == Half.BOTTOM + && (blockState = level.getBlockState(blockPos = pos.above())).is(state.getBlock()) + && blockState.getValue(HALF) == Half.MID + && (blockState1 = level.getBlockState(blockPos1 = blockPos.above())).is(state.getBlock()) + && blockState1.getValue(HALF) == Half.TOP + ) { + breakOtherPart(level, blockPos, blockState, blockPos1, blockState1, player); + } + } + + private static void breakOtherPart( + @NotNull Level level, BlockPos blockPos, @NotNull BlockState blockState, + BlockPos blockPos1, @NotNull BlockState blockState1, Player player + ) { + BlockState blockState2 = Blocks.AIR.defaultBlockState(); + level.setBlock(blockPos, blockState2, 35); + level.levelEvent(player, 2001, blockPos, Block.getId(blockState)); + level.setBlock(blockPos1, blockState2, 35); + level.levelEvent(player, 2001, blockPos1, Block.getId(blockState1)); + } + + @Nullable + @Override + public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { + return new TransmissionPoleBlockEntity(pos, state); + } + + @Override + @SuppressWarnings("deprecation") + public boolean canSurvive(@NotNull BlockState state, @NotNull LevelReader level, @NotNull BlockPos pos) { + switch (state.getValue(HALF)) { + case TOP -> { + BlockState state1 = level.getBlockState(pos.below()); + BlockState state2 = level.getBlockState(pos.below(2)); + return state1.is(this) && state2.is(this); + } + case MID -> { + BlockState state2 = level.getBlockState(pos.below()); + return state2.is(this); + } + default -> { + return state.isFaceSturdy(level, pos.below(), Direction.UP); + } + } + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/AutoCrafterBlockEntity.java b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/AutoCrafterBlockEntity.java index c1abc8b89..1c4c6ae8f 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/AutoCrafterBlockEntity.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/AutoCrafterBlockEntity.java @@ -128,7 +128,7 @@ public void fillStackedContents(StackedContents contents) { }; - public AutoCrafterBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { + protected AutoCrafterBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { super(type, pos, blockState); } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/ChuteBlockEntity.java b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/ChuteBlockEntity.java index 09037554f..aacd83c02 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/ChuteBlockEntity.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/ChuteBlockEntity.java @@ -39,7 +39,7 @@ public void onContentsChanged(int slot) { } }; - public ChuteBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { + protected ChuteBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { super(type, pos, blockState); } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/CorruptedBeaconBlockEntity.java b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/CorruptedBeaconBlockEntity.java index c09c537d5..e5568caf1 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/CorruptedBeaconBlockEntity.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/CorruptedBeaconBlockEntity.java @@ -2,6 +2,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import dev.dubhe.anvilcraft.init.ModBlockEntities; import lombok.Getter; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; @@ -33,16 +34,20 @@ public class CorruptedBeaconBlockEntity extends BlockEntity { int levels; private int lastCheckY; - public CorruptedBeaconBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { - super(type, pos, blockState); - } - public static @NotNull CorruptedBeaconBlockEntity createBlockEntity( BlockEntityType type, BlockPos pos, BlockState blockState ) { return new CorruptedBeaconBlockEntity(type, pos, blockState); } + public CorruptedBeaconBlockEntity(BlockPos pos, BlockState blockState) { + this(ModBlockEntities.CORRUPTED_BEACON.get(), pos, blockState); + } + + private CorruptedBeaconBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { + super(type, pos, blockState); + } + /** * tick 逻辑 * diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/CreativeDynamoBlockEntity.java b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/CreativeDynamoBlockEntity.java new file mode 100644 index 000000000..5eb00ac22 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/CreativeDynamoBlockEntity.java @@ -0,0 +1,92 @@ +package dev.dubhe.anvilcraft.block.entity; + +import dev.dubhe.anvilcraft.api.power.IPowerConsumer; +import dev.dubhe.anvilcraft.api.power.IPowerProducer; +import dev.dubhe.anvilcraft.api.power.PowerComponentType; +import dev.dubhe.anvilcraft.api.power.PowerGrid; +import dev.dubhe.anvilcraft.init.ModBlockEntities; +import dev.dubhe.anvilcraft.init.ModBlocks; +import dev.dubhe.anvilcraft.inventory.SliderMenu; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +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 org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +@Getter +public class CreativeDynamoBlockEntity extends BlockEntity implements IPowerProducer, IPowerConsumer, MenuProvider { + private PowerGrid grid = null; + @Setter + private int power = 16; + + public static @NotNull CreativeDynamoBlockEntity createBlockEntity( + BlockEntityType type, BlockPos pos, BlockState blockState + ) { + return new CreativeDynamoBlockEntity(type, pos, blockState); + } + + public CreativeDynamoBlockEntity(BlockPos pos, BlockState blockState) { + this(ModBlockEntities.CREATIVE_DYNAMO.get(), pos, blockState); + } + + private CreativeDynamoBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { + super(type, pos, blockState); + } + + @Override + protected void saveAdditional(@NotNull CompoundTag tag) { + super.saveAdditional(tag); + tag.putInt("power", power); + } + + @Override + public void load(@NotNull CompoundTag tag) { + super.load(tag); + this.power = tag.getInt("power"); + } + + @Override + public int getOutputPower() { + return this.power > 0 ? this.power : 0; + } + + @Override + public int getInputPower() { + return this.power < 0 ? -this.power : 0; + } + + @Override + public @NotNull PowerComponentType getComponentType() { + return this.power > 0 ? PowerComponentType.PRODUCER : PowerComponentType.CONSUMER; + } + + @Override + public @NotNull BlockPos getPos() { + return this.getBlockPos(); + } + + @Override + public void setGrid(PowerGrid grid) { + this.grid = grid; + } + + @Override + public @NotNull Component getDisplayName() { + return ModBlocks.CREATIVE_DYNAMO.get().getName(); + } + + @Nullable + @Override + public AbstractContainerMenu createMenu(int i, @NotNull Inventory inventory, @NotNull Player player) { + return new SliderMenu(i, -8192, 8192, this::setPower); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/HeaterBlockEntity.java b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/HeaterBlockEntity.java new file mode 100644 index 000000000..f75d080a2 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/HeaterBlockEntity.java @@ -0,0 +1,70 @@ +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.HeaterBlock; +import dev.dubhe.anvilcraft.init.ModBlockEntities; +import dev.dubhe.anvilcraft.init.ModBlocks; +import lombok.Getter; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +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 org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +@Getter +public class HeaterBlockEntity extends BlockEntity implements IPowerConsumer { + private static final int POWER = 8; + private PowerGrid grid = null; + + public HeaterBlockEntity(BlockPos pos, BlockState blockState) { + this(ModBlockEntities.HEATER.get(), pos, blockState); + } + + public static @NotNull HeaterBlockEntity createBlockEntity( + BlockEntityType type, BlockPos pos, BlockState blockState + ) { + return new HeaterBlockEntity(type, pos, blockState); + } + + private HeaterBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { + super(type, pos, blockState); + } + + @Override + public int getInputPower() { + return HeaterBlockEntity.POWER; + } + + @Override + public @NotNull BlockPos getPos() { + return this.getBlockPos(); + } + + @Override + public void setGrid(@Nullable PowerGrid grid) { + this.grid = grid; + } + + /** + * @param level 世界 + * @param pos 位置 + */ + public void tick(@NotNull Level level, @NotNull BlockPos pos) { + BlockState state = level.getBlockState(pos); + if (!state.is(ModBlocks.HEATER.get())) return; + if (this.grid == null) { + if (state.getValue(HeaterBlock.LIT)) { + level.setBlockAndUpdate(pos, state.setValue(HeaterBlock.LIT, false)); + } + return; + } + if (this.grid.isWork() && !state.getValue(HeaterBlock.LIT)) { + level.setBlockAndUpdate(pos, state.setValue(HeaterBlock.LIT, true)); + } else if (!this.grid.isWork() && state.getValue(HeaterBlock.LIT)) { + level.setBlockAndUpdate(pos, state.setValue(HeaterBlock.LIT, false)); + } + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/SimpleChuteBlockEntity.java b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/SimpleChuteBlockEntity.java index f73d85779..8e07f6308 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/SimpleChuteBlockEntity.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/SimpleChuteBlockEntity.java @@ -28,7 +28,7 @@ public void onContentsChanged(int slot) { } }; - public SimpleChuteBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { + protected SimpleChuteBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { super(type, pos, blockState); } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/entity/TransmissionPoleBlockEntity.java b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/TransmissionPoleBlockEntity.java new file mode 100644 index 000000000..8b631a0be --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/entity/TransmissionPoleBlockEntity.java @@ -0,0 +1,49 @@ +package dev.dubhe.anvilcraft.block.entity; + +import dev.dubhe.anvilcraft.api.power.IPowerTransmitter; +import dev.dubhe.anvilcraft.api.power.PowerComponentType; +import dev.dubhe.anvilcraft.api.power.PowerGrid; +import dev.dubhe.anvilcraft.block.TransmissionPoleBlock; +import dev.dubhe.anvilcraft.block.state.Half; +import dev.dubhe.anvilcraft.init.ModBlockEntities; +import dev.dubhe.anvilcraft.init.ModBlocks; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.core.BlockPos; +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 org.jetbrains.annotations.NotNull; + +@Getter +@Setter +public class TransmissionPoleBlockEntity extends BlockEntity implements IPowerTransmitter { + private PowerGrid grid; + + public TransmissionPoleBlockEntity(BlockPos pos, BlockState blockState) { + this(ModBlockEntities.REMOTE_TRANSMISSION_POLE.get(), pos, blockState); + } + + public static @NotNull TransmissionPoleBlockEntity createBlockEntity( + BlockEntityType type, BlockPos pos, BlockState blockState + ) { + return new TransmissionPoleBlockEntity(type, pos, blockState); + } + + private TransmissionPoleBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { + super(type, pos, blockState); + } + + @Override + public @NotNull BlockPos getPos() { + return this.getBlockPos(); + } + + @Override + public @NotNull PowerComponentType getComponentType() { + if (this.getLevel() == null) return PowerComponentType.INVALID; + if (!this.getBlockState().is(ModBlocks.TRANSMISSION_POLE.get())) return PowerComponentType.INVALID; + if (this.getBlockState().getValue(TransmissionPoleBlock.HALF) != Half.TOP) return PowerComponentType.INVALID; + return PowerComponentType.TRANSMITTER; + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/block/state/Half.java b/common/src/main/java/dev/dubhe/anvilcraft/block/state/Half.java new file mode 100644 index 000000000..90ea11fb3 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/block/state/Half.java @@ -0,0 +1,26 @@ +package dev.dubhe.anvilcraft.block.state; + +import net.minecraft.util.StringRepresentable; +import org.jetbrains.annotations.NotNull; + +public enum Half implements StringRepresentable { + TOP("top"), + MID("mid"), + BOTTOM("bottom"); + + + private final String name; + + Half(String name) { + this.name = name; + } + + public String toString() { + return this.name; + } + + @Override + public @NotNull String getSerializedName() { + return this.name; + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/component/EnableFilterButton.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/component/EnableFilterButton.java index b1cd92372..534a0e904 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/component/EnableFilterButton.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/component/EnableFilterButton.java @@ -18,8 +18,8 @@ @Getter public class EnableFilterButton extends Button { private final Supplier filterEnabled; - private static final ResourceLocation YES = AnvilCraft.of("textures/gui/container/button_yes.png"); - private static final ResourceLocation NO = AnvilCraft.of("textures/gui/container/button_no.png"); + private static final ResourceLocation YES = AnvilCraft.of("textures/gui/container/machine/button_yes.png"); + private static final ResourceLocation NO = AnvilCraft.of("textures/gui/container/machine/button_no.png"); private static final MutableComponent defaultMessage = Component .translatable("screen.anvilcraft.button.record", Component.translatable("screen.anvilcraft.button.off")); diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/component/OutputDirectionButton.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/component/OutputDirectionButton.java index 29babd838..777250b51 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/component/OutputDirectionButton.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/component/OutputDirectionButton.java @@ -18,12 +18,12 @@ public class OutputDirectionButton extends Button { private Direction direction; private final List skip = new ArrayList<>(); - private static final ResourceLocation UP = AnvilCraft.of("textures/gui/container/button_u.png"); - private static final ResourceLocation DOWN = AnvilCraft.of("textures/gui/container/button_d.png"); - private static final ResourceLocation EAST = AnvilCraft.of("textures/gui/container/button_e.png"); - private static final ResourceLocation WEST = AnvilCraft.of("textures/gui/container/button_w.png"); - private static final ResourceLocation SOUTH = AnvilCraft.of("textures/gui/container/button_s.png"); - private static final ResourceLocation NORTH = AnvilCraft.of("textures/gui/container/button_n.png"); + private static final ResourceLocation UP = AnvilCraft.of("textures/gui/container/machine/button_u.png"); + private static final ResourceLocation DOWN = AnvilCraft.of("textures/gui/container/machine/button_d.png"); + private static final ResourceLocation EAST = AnvilCraft.of("textures/gui/container/machine/button_e.png"); + private static final ResourceLocation WEST = AnvilCraft.of("textures/gui/container/machine/button_w.png"); + private static final ResourceLocation SOUTH = AnvilCraft.of("textures/gui/container/machine/button_s.png"); + private static final ResourceLocation NORTH = AnvilCraft.of("textures/gui/container/machine/button_n.png"); private static final MutableComponent defaultMessage = Component.translatable("screen.anvilcraft.button.direction", Component.translatable("screen.anvilcraft.button.direction.up")); diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/component/Slider.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/component/Slider.java new file mode 100644 index 000000000..b8d310dee --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/component/Slider.java @@ -0,0 +1,159 @@ +package dev.dubhe.anvilcraft.client.gui.component; + +import dev.dubhe.anvilcraft.AnvilCraft; +import dev.dubhe.anvilcraft.inventory.SliderMenu; +import lombok.Getter; +import lombok.Setter; +import net.minecraft.Util; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraft.client.gui.narration.NarrationElementOutput; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; + +public class Slider extends AbstractWidget { + public static final ResourceLocation SLIDER = AnvilCraft.of("textures/gui/container/slider/slider.png"); + @Setter + @Getter + private int min; + @Setter + @Getter + private int max; + @Getter + private int value; + private final int posX; + private final int posY; + private final int length; + public final SliderMenu.Update update; + private int tooltipMsDelay; + private long hoverOrFocusedStartTime; + private boolean wasHoveredOrFocused; + + /** + * @param x X + * @param y Y + * @param min 最小值 + * @param max 最大值 + * @param length 长度 + * @param update 更新回调 + */ + public Slider(int x, int y, int min, int max, int length, SliderMenu.Update update) { + super(x, y, length, 8, Component.literal("Slider")); + this.posX = x; + this.posY = y; + this.min = min; + this.max = max; + this.length = length; + this.update = update; + } + + public double getProportion() { + return Math.max(0.0, Math.min(1.0, (double) (value - this.min) / (this.max - this.min))); + } + + public void setProportion(double proportion) { + this.value = (int) ((max - min) * proportion + min); + } + + public void setValue(int value) { + this.value = Math.max(this.min, Math.min(this.max, value)); + } + + /** + * @param value 设置 Value 并更新 + */ + public void setValueWithUpdate(int value) { + if (this.value == value) return; + this.setValue(value); + this.update(); + } + + private void update() { + if (this.update != null) this.update.update(this.value); + } + + @Override + public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) { + if (button == 0) { + this.onDrag(mouseX, mouseY, dragX, dragY); + return true; + } + return false; + } + + @Override + public void onClick(double mouseX, double mouseY) { + super.onClick(mouseX, mouseY); + if (!isInRange(mouseX, mouseY)) return; + if (isInSlider(mouseX, mouseY)) { + super.onClick(mouseX, mouseY); + return; + } + double offset = 16.0 / this.length; + int offsetX = posX + (int) ((length - 16) * this.getProportion()); + if (mouseX < offsetX) this.setProportion(Math.max(0.0, this.getProportion() - offset)); + else this.setProportion(Math.min(1.0, this.getProportion() + offset)); + this.update(); + } + + @Override + protected void onDrag(double mouseX, double mouseY, double dragX, double dragY) { + super.onDrag(mouseX, mouseY, dragX, dragY); + if (!isInSlider(mouseX, mouseY)) return; + double offset = dragX - mouseX / this.length; + this.setProportion(Math.max(0.0, Math.min(1.0, this.getProportion() + offset))); + this.update(); + } + + protected boolean isInSlider(double mouseX, double mouseY) { + int offsetX = posX + (int) ((length - 16) * this.getProportion()); + return mouseX > offsetX && mouseX < offsetX + 16 && mouseY > posY && mouseY < posY + 8; + } + + protected boolean isInRange(double mouseX, double mouseY) { + return mouseX > posX && mouseX < posX + length && mouseY > posY && mouseY < posY + 8; + } + + @Override + public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + if (!this.visible) return; + this.isHovered = this.isInRange(mouseX, mouseY); + this.renderWidget(guiGraphics, mouseX, mouseY, partialTick); + this.updateTooltip(); + } + + @Override + protected void renderWidget(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) { + int offsetX = posX + (int) ((length - 16) * this.getProportion()); + guiGraphics.blit(SLIDER, offsetX, posY, 0, this.isHovered ? 8 : 0, 16, 8, 16, 16); + } + + @Override + protected void updateWidgetNarration(@NotNull NarrationElementOutput narrationElementOutput) { + } + + private void updateTooltip() { + if (this.getTooltip() == null) return; + boolean bl = this.isHovered || this.isFocused() && Minecraft.getInstance().getLastInputType().isKeyboard(); + if (bl != this.wasHoveredOrFocused) { + if (bl) this.hoverOrFocusedStartTime = Util.getMillis(); + this.wasHoveredOrFocused = bl; + } + Screen screen; + if (bl + && Util.getMillis() - this.hoverOrFocusedStartTime > (long) this.tooltipMsDelay + && (screen = Minecraft.getInstance().screen) != null + ) { + screen.setTooltipForNextRenderPass(this.getTooltip(), this.createTooltipPositioner(), this.isFocused()); + } + } + + @Override + public void setTooltipDelay(int tooltipMsDelay) { + super.setTooltipDelay(tooltipMsDelay); + this.tooltipMsDelay = tooltipMsDelay; + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/AutoCrafterScreen.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/AutoCrafterScreen.java index 8348a9d2f..be5c396ee 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/AutoCrafterScreen.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/AutoCrafterScreen.java @@ -18,7 +18,8 @@ import java.util.function.BiFunction; public class AutoCrafterScreen extends BaseMachineScreen implements IFilterScreen { - private static final ResourceLocation CONTAINER_LOCATION = AnvilCraft.of("textures/gui/container/auto_crafter.png"); + private static final ResourceLocation CONTAINER_LOCATION = + AnvilCraft.of("textures/gui/container/machine/background/auto_crafter.png"); BiFunction enableFilterButtonSupplier = this .getEnableFilterButtonSupplier(116, 18); @Getter diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/ChuteScreen.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/ChuteScreen.java index f9913cb6b..3c192b9cb 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/ChuteScreen.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/ChuteScreen.java @@ -20,7 +20,8 @@ import java.util.function.BiFunction; public class ChuteScreen extends BaseMachineScreen implements IFilterScreen { - private static final ResourceLocation CONTAINER_LOCATION = AnvilCraft.of("textures/gui/container/chute.png"); + private static final ResourceLocation CONTAINER_LOCATION = + AnvilCraft.of("textures/gui/container/machine/background/chute.png"); BiFunction enableFilterButtonSupplier = this diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/IFilterScreen.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/IFilterScreen.java index bb3bae113..7b9874f23 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/IFilterScreen.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/IFilterScreen.java @@ -18,7 +18,7 @@ * 有过滤的 GUI */ public interface IFilterScreen { - ResourceLocation DISABLED_SLOT = AnvilCraft.of("textures/gui/container/disabled_slot.png"); + ResourceLocation DISABLED_SLOT = AnvilCraft.of("textures/gui/container/machine/disabled_slot.png"); IFilterMenu getFilterMenu(); diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalAnvilScreen.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalAnvilScreen.java index 3234a5711..dadd2561b 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalAnvilScreen.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalAnvilScreen.java @@ -17,10 +17,12 @@ import org.jetbrains.annotations.NotNull; public class RoyalAnvilScreen extends ItemCombinerScreen { - private static final ResourceLocation ANVIL_LOCATION = AnvilCraft.of("textures/gui/container/royal_anvil.png"); - private static final ResourceLocation TEXT_LOCATION = AnvilCraft.of("textures/gui/container/text_field.png"); - private static final ResourceLocation TEXT_DISABLE_LOCATION = AnvilCraft - .of("textures/gui/container/text_field_disabled.png"); + private static final ResourceLocation ANVIL_LOCATION = + AnvilCraft.of("textures/gui/container/smithing/background/royal_anvil.png"); + private static final ResourceLocation TEXT_LOCATION = + AnvilCraft.of("textures/gui/container/smithing/text_field.png"); + private static final ResourceLocation TEXT_DISABLE_LOCATION = + AnvilCraft.of("textures/gui/container/smithing/text_field_disabled.png"); private EditBox name; private final Player player; diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalGrindstoneScreen.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalGrindstoneScreen.java index c002d67eb..fa6f1fcc8 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalGrindstoneScreen.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalGrindstoneScreen.java @@ -11,7 +11,7 @@ public class RoyalGrindstoneScreen extends AbstractContainerScreen { private static final ResourceLocation GRINDSTONE_LOCATION = - AnvilCraft.of("textures/gui/container/royal_grindstone.png"); + AnvilCraft.of("textures/gui/container/smithing/background/royal_grindstone.png"); public RoyalGrindstoneScreen( RoyalGrindstoneMenu menu, Inventory playerInventory, @SuppressWarnings("unused") Component title diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalSmithingScreen.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalSmithingScreen.java index a77d112c6..3849401b8 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalSmithingScreen.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/RoyalSmithingScreen.java @@ -25,8 +25,9 @@ public class RoyalSmithingScreen extends ItemCombinerScreen { private static final ResourceLocation SMITHING_LOCATION = - AnvilCraft.of("textures/gui/container/royal_smithing_table.png"); - private static final ResourceLocation ERROR = AnvilCraft.of("textures/gui/container/error.png"); + AnvilCraft.of("textures/gui/container/smithing/background/royal_smithing_table.png"); + private static final ResourceLocation ERROR = + AnvilCraft.of("textures/gui/container/smithing/error.png"); private static final ResourceLocation EMPTY_SLOT_SMITHING_TEMPLATE_ARMOR_TRIM = new ResourceLocation("item/empty_slot_smithing_template_armor_trim"); private static final ResourceLocation EMPTY_SLOT_SMITHING_TEMPLATE_NETHERITE_UPGRADE = diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/SliderScreen.java b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/SliderScreen.java new file mode 100644 index 000000000..44c5ac5c2 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/gui/screen/inventory/SliderScreen.java @@ -0,0 +1,128 @@ +package dev.dubhe.anvilcraft.client.gui.screen.inventory; + +import dev.dubhe.anvilcraft.AnvilCraft; +import dev.dubhe.anvilcraft.client.gui.component.Slider; +import dev.dubhe.anvilcraft.inventory.SliderMenu; +import dev.dubhe.anvilcraft.network.SliderUpdatePack; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.EditBox; +import net.minecraft.client.gui.components.ImageButton; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import org.jetbrains.annotations.NotNull; + +public class SliderScreen extends AbstractContainerScreen { + public static final ResourceLocation LOCATION = AnvilCraft.of("textures/gui/container/slider/background.png"); + public static final ResourceLocation BUTTON_MAX = AnvilCraft.of("textures/gui/container/slider/button_max.png"); + public static final ResourceLocation BUTTON_ADD = AnvilCraft.of("textures/gui/container/slider/button_add.png"); + public static final ResourceLocation BUTTON_MINUS = AnvilCraft.of("textures/gui/container/slider/button_minus.png"); + public static final ResourceLocation BUTTON_MIN = AnvilCraft.of("textures/gui/container/slider/button_min.png"); + private Slider slider = null; + private EditBox value; + + /** + * @param menu 菜单 + * @param inventory 背包 + * @param title 标题 + */ + public SliderScreen(SliderMenu menu, Inventory inventory, Component title) { + super(menu, inventory, title); + this.imageWidth = 176; + this.imageHeight = 77; + } + + @Override + protected void init() { + super.init(); + this.titleLabelX = (this.imageWidth - this.font.width(this.title)) / 2; + int offsetX = (this.width - this.imageWidth) / 2; + int offsetY = (this.height - this.imageHeight) / 2; + this.slider = new Slider(8 + offsetX, 31 + offsetY, 0, 16, 160, this::update); + this.value = new EditBox(this.font, offsetX + 50, offsetY + 47, 76, 8, Component.literal("value")); + this.value.setCanLoseFocus(false); + this.value.setTextColor(-1); + this.value.setTextColorUneditable(-1); + this.value.setBordered(false); + this.value.setMaxLength(50); + this.value.setResponder(this::onValueInput); + this.value.setValue(""); + ImageButton max = new ImageButton( + 152 + offsetX, 43 + offsetY, + 16, 16, 0, 0, 16, BUTTON_MAX, 16, 32, + (btn) -> this.slider.setValueWithUpdate(slider.getMax()) + ); + ImageButton add = new ImageButton( + 134 + offsetX, 43 + offsetY, + 16, 16, 0, 0, 16, BUTTON_ADD, 16, 32, + (btn) -> this.slider.setValueWithUpdate(Math.min(slider.getMax(), slider.getValue() + 1)) + ); + ImageButton min = new ImageButton( + 8 + offsetX, 43 + offsetY, + 16, 16, 0, 0, 16, BUTTON_MIN, 16, 32, + (btn) -> this.slider.setValueWithUpdate(slider.getMin()) + ); + ImageButton minus = new ImageButton( + 26 + offsetX, 43 + offsetY, + 16, 16, 0, 0, 16, BUTTON_MINUS, 16, 32, + (btn) -> this.slider.setValueWithUpdate(Math.max(slider.getMin(), slider.getValue() - 1)) + ); + this.addRenderableWidget(max); + this.addRenderableWidget(add); + this.addRenderableWidget(min); + this.addRenderableWidget(minus); + this.addRenderableWidget(this.slider); + this.addRenderableWidget(this.value); + this.setInitialFocus(this.value); + } + + public void setValue(int value) { + if (this.slider != null) slider.setValue(value); + this.value.setValue("" + value); + } + + private void onValueInput(@NotNull String value) { + String regex = "^[+-]?[0-9]+$"; + int v; + if (value.matches(regex)) { + v = Integer.parseInt(value); + } else if (value.isEmpty()) { + v = 0; + } else if (value.equals("-")) { + return; + } else if (value.equals("0-")) { + this.value.setValue("-"); + return; + } else { + this.value.setValue("" + this.slider.getValue()); + return; + } + this.slider.setValueWithUpdate(v); + } + + public void setMin(int min) { + if (this.slider != null) slider.setMin(min); + } + + public void setMax(int max) { + if (this.slider != null) slider.setMax(max); + } + + @Override + protected void renderLabels(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) { + guiGraphics.drawString(this.font, this.title, this.titleLabelX, this.titleLabelY, 0x404040, false); + } + + @Override + protected void renderBg(@NotNull GuiGraphics guiGraphics, float partialTick, int mouseX, int mouseY) { + int offsetX = (this.width - this.imageWidth) / 2; + int offsetY = (this.height - this.imageHeight) / 2; + guiGraphics.blit(LOCATION, offsetX, offsetY, 0, 0, this.imageWidth, this.imageHeight, 256, 128); + } + + private void update(int value) { + new SliderUpdatePack(value).send(); + this.value.setValue("" + value); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/client/renderer/PowerGridRenderer.java b/common/src/main/java/dev/dubhe/anvilcraft/client/renderer/PowerGridRenderer.java new file mode 100644 index 000000000..2388545ea --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/client/renderer/PowerGridRenderer.java @@ -0,0 +1,66 @@ +package dev.dubhe.anvilcraft.client.renderer; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import dev.dubhe.anvilcraft.api.power.PowerGrid; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.Minecraft; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; + +@Environment(EnvType.CLIENT) +public class PowerGridRenderer { + /** + * 渲染 + */ + public static void render(PoseStack poseStack, VertexConsumer consumer, double camX, double camY, double camZ) { + if (Minecraft.getInstance().level == null) return; + RandomSource random = Minecraft.getInstance().level.random; + for (PowerGrid grid : PowerGrid.getGridSetClient()) { + random.setSeed(grid.hashCode()); + PowerGridRenderer.renderOutline( + poseStack, consumer, camX, camY, camZ, + grid.getPos(), grid.getRange(), + random.nextFloat(), random.nextFloat(), random.nextFloat(), 0.4f + ); + } + } + + @SuppressWarnings("SameParameterValue") + private static void renderOutline( + PoseStack poseStack, VertexConsumer consumer, + double camX, double camY, double camZ, @NotNull BlockPos pos, @NotNull VoxelShape shape, + float red, float green, float blue, float alpha + ) { + PowerGridRenderer.renderShape( + poseStack, consumer, shape, + (double) pos.getX() - camX, (double) pos.getY() - camY, (double) pos.getZ() - camZ, + red, green, blue, alpha + ); + } + + private static void renderShape( + @NotNull PoseStack poseStack, VertexConsumer consumer, @NotNull VoxelShape shape, + double x, double y, double z, float red, float green, float blue, float alpha + ) { + PoseStack.Pose pose = poseStack.last(); + shape.forAllEdges((minX, minY, minZ, maxX, maxY, maxZ) -> { + float k = (float) (maxX - minX); + float l = (float) (maxY - minY); + float m = (float) (maxZ - minZ); + float n = Mth.sqrt(k * k + l * l + m * m); + consumer.vertex(pose.pose(), (float) (minX + x), (float) (minY + y), (float) (minZ + z)) + .color(red, green, blue, alpha) + .normal(pose.normal(), k /= n, l /= n, m /= n) + .endVertex(); + consumer.vertex(pose.pose(), (float) (maxX + x), (float) (maxY + y), (float) (maxZ + z)) + .color(red, green, blue, alpha) + .normal(pose.normal(), k, l, m) + .endVertex(); + }); + } +} 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 0da0ad353..f374c32ad 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/config/AnvilCraftConfig.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/config/AnvilCraftConfig.java @@ -74,4 +74,10 @@ public class AnvilCraftConfig implements ConfigData { @ConfigEntry.BoundedDiscrete(max = 30, min = 5) @SerializedName("Geode Search Cooldown") public int geodeCooldown = 5; + + @Comment("The power transmitter can identify the range of the power transmitter") + @ConfigEntry.Gui.Tooltip + @ConfigEntry.BoundedDiscrete(max = 64, min = 1) + @SerializedName("Range of Power Transmitter") + public int powerTransmitterRange = 8; } \ No newline at end of file diff --git a/common/src/main/java/dev/dubhe/anvilcraft/data/generator/AnvilCraftDatagen.java b/common/src/main/java/dev/dubhe/anvilcraft/data/generator/AnvilCraftDatagen.java index 5282f40b6..b9275b4ce 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/data/generator/AnvilCraftDatagen.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/data/generator/AnvilCraftDatagen.java @@ -33,7 +33,11 @@ public static void init() { return RegistrateRecipeProvider.has(tag); } - public static @NotNull String hasItem(@NotNull Item item) { - return "has_" + BuiltInRegistries.ITEM.getKey(item).getPath(); + public static @NotNull String hasItem(@NotNull TagKey item) { + return "has_" + item.location().getPath(); + } + + public static @NotNull String hasItem(@NotNull ItemLike item) { + return "has_" + BuiltInRegistries.ITEM.getKey(item.asItem()).getPath(); } } 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 1e4deae38..bd610a2b5 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlockEntities.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlockEntities.java @@ -4,6 +4,9 @@ import dev.dubhe.anvilcraft.block.entity.AutoCrafterBlockEntity; import dev.dubhe.anvilcraft.block.entity.ChuteBlockEntity; import dev.dubhe.anvilcraft.block.entity.CorruptedBeaconBlockEntity; +import dev.dubhe.anvilcraft.block.entity.CreativeDynamoBlockEntity; +import dev.dubhe.anvilcraft.block.entity.HeaterBlockEntity; +import dev.dubhe.anvilcraft.block.entity.TransmissionPoleBlockEntity; import dev.dubhe.anvilcraft.block.entity.SimpleChuteBlockEntity; import dev.dubhe.anvilcraft.client.renderer.blockentity.CorruptedBeaconRenderer; @@ -11,28 +14,43 @@ public class ModBlockEntities { public static final BlockEntityEntry AUTO_CRAFTER = REGISTRATE - .blockEntity("auto_crafter", AutoCrafterBlockEntity::createBlockEntity) - .onRegister(AutoCrafterBlockEntity::onBlockEntityRegister) - .validBlock(ModBlocks.AUTO_CRAFTER) - .register(); + .blockEntity("auto_crafter", AutoCrafterBlockEntity::createBlockEntity) + .onRegister(AutoCrafterBlockEntity::onBlockEntityRegister) + .validBlock(ModBlocks.AUTO_CRAFTER) + .register(); public static final BlockEntityEntry CHUTE = REGISTRATE - .blockEntity("chute", ChuteBlockEntity::createBlockEntity) - .onRegister(ChuteBlockEntity::onBlockEntityRegister) - .validBlock(ModBlocks.CHUTE) - .register(); + .blockEntity("chute", ChuteBlockEntity::createBlockEntity) + .onRegister(ChuteBlockEntity::onBlockEntityRegister) + .validBlock(ModBlocks.CHUTE) + .register(); public static final BlockEntityEntry SIMPLE_CHUTE = REGISTRATE - .blockEntity("simple_chute", SimpleChuteBlockEntity::createBlockEntity) - .onRegister(SimpleChuteBlockEntity::onBlockEntityRegister) - .validBlock(ModBlocks.SIMPLE_CHUTE) - .register(); + .blockEntity("simple_chute", SimpleChuteBlockEntity::createBlockEntity) + .onRegister(SimpleChuteBlockEntity::onBlockEntityRegister) + .validBlock(ModBlocks.SIMPLE_CHUTE) + .register(); public static final BlockEntityEntry CORRUPTED_BEACON = REGISTRATE - .blockEntity("corrupted_beacon", CorruptedBeaconBlockEntity::createBlockEntity) - .validBlock(ModBlocks.CORRUPTED_BEACON) - .renderer(() -> CorruptedBeaconRenderer::new) - .register(); + .blockEntity("corrupted_beacon", CorruptedBeaconBlockEntity::createBlockEntity) + .validBlock(ModBlocks.CORRUPTED_BEACON) + .renderer(() -> CorruptedBeaconRenderer::new) + .register(); + + public static final BlockEntityEntry CREATIVE_DYNAMO = REGISTRATE + .blockEntity("creative_dynamo", CreativeDynamoBlockEntity::createBlockEntity) + .validBlock(ModBlocks.CREATIVE_DYNAMO) + .register(); + + public static final BlockEntityEntry HEATER = REGISTRATE + .blockEntity("heater", HeaterBlockEntity::createBlockEntity) + .validBlock(ModBlocks.HEATER) + .register(); + + public static final BlockEntityEntry REMOTE_TRANSMISSION_POLE = REGISTRATE + .blockEntity("transmission_pole", TransmissionPoleBlockEntity::createBlockEntity) + .validBlock(ModBlocks.TRANSMISSION_POLE) + .register(); public static void register() { } 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 3761d340b..b45abe94c 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlocks.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModBlocks.java @@ -6,10 +6,13 @@ import dev.dubhe.anvilcraft.block.AutoCrafterBlock; import dev.dubhe.anvilcraft.block.ChuteBlock; import dev.dubhe.anvilcraft.block.CorruptedBeaconBlock; +import dev.dubhe.anvilcraft.block.CreativeDynamoBlock; import dev.dubhe.anvilcraft.block.FerriteCoreMagnetBlock; +import dev.dubhe.anvilcraft.block.HeaterBlock; import dev.dubhe.anvilcraft.block.HollowMagnetBlock; import dev.dubhe.anvilcraft.block.LavaCauldronBlock; import dev.dubhe.anvilcraft.block.MagnetBlock; +import dev.dubhe.anvilcraft.block.TransmissionPoleBlock; import dev.dubhe.anvilcraft.block.RoyalAnvilBlock; import dev.dubhe.anvilcraft.block.RoyalGrindstone; import dev.dubhe.anvilcraft.block.RoyalSmithingTableBlock; @@ -37,344 +40,402 @@ public class ModBlocks { public static final BlockEntry STAMPING_PLATFORM = REGISTRATE - .block("stamping_platform", StampingPlatformBlock::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .blockstate((ctx, provider) -> { - }) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ctx.get()) - .pattern("BAB") - .pattern("B B") - .pattern("B B") - .define('A', ModItemTags.IRON_PLATES) - .define('B', Items.IRON_INGOT) - .unlockedBy("has_" + ModItemTags.IRON_PLATES.location().getPath(), - AnvilCraftDatagen.has(ModItemTags.IRON_PLATES)) - .unlockedBy(AnvilCraftDatagen.hasItem(Items.IRON_INGOT), AnvilCraftDatagen.has(Items.IRON_INGOT)) - .save(provider)) - .register(); + .block("stamping_platform", StampingPlatformBlock::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .blockstate((ctx, provider) -> { + }) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ctx.get()) + .pattern("BAB") + .pattern("B B") + .pattern("B B") + .define('A', ModItemTags.IRON_PLATES) + .define('B', Items.IRON_INGOT) + .unlockedBy("has_" + ModItemTags.IRON_PLATES.location().getPath(), + AnvilCraftDatagen.has(ModItemTags.IRON_PLATES)) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.IRON_INGOT), AnvilCraftDatagen.has(Items.IRON_INGOT)) + .save(provider)) + .register(); public static final BlockEntry CORRUPTED_BEACON = REGISTRATE - .block("corrupted_beacon", CorruptedBeaconBlock::new) - .initialProperties(() -> Blocks.BEACON) - .blockstate((ctx, provider) -> { - }) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE) - .register(); + .block("corrupted_beacon", CorruptedBeaconBlock::new) + .initialProperties(() -> Blocks.BEACON) + .blockstate((ctx, provider) -> { + }) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .register(); public static final BlockEntry ROYAL_ANVIL = REGISTRATE - .block("royal_anvil", RoyalAnvilBlock::new) - .initialProperties(() -> Blocks.ANVIL) - .blockstate((ctx, provider) -> { - }) - .simpleItem() - .defaultLoot() - .tag(BlockTags.ANVIL, ModBlockTags.CANT_BROKEN_ANVIL, BlockTags.MINEABLE_WITH_PICKAXE) - .register(); + .block("royal_anvil", RoyalAnvilBlock::new) + .initialProperties(() -> Blocks.ANVIL) + .blockstate((ctx, provider) -> { + }) + .simpleItem() + .defaultLoot() + .tag(BlockTags.ANVIL, ModBlockTags.CANT_BROKEN_ANVIL, BlockTags.MINEABLE_WITH_PICKAXE) + .register(); public static final BlockEntry MAGNET_BLOCK = REGISTRATE - .block("magnet_block", MagnetBlock::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .blockstate((ctx, provider) -> { - }) - .simpleItem() - .defaultLoot() - .tag(ModBlockTags.MAGNET, BlockTags.MINEABLE_WITH_PICKAXE) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ctx.get()) - .pattern("AAA") - .pattern("AAA") - .pattern("AAA") - .define('A', ModItems.MAGNET_INGOT) - .unlockedBy("hasitem", RegistrateRecipeProvider.has(ModItems.MAGNET_INGOT)) - .save(provider) - ) - .register(); + .block("magnet_block", MagnetBlock::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .blockstate((ctx, provider) -> { + }) + .simpleItem() + .defaultLoot() + .tag(ModBlockTags.MAGNET, BlockTags.MINEABLE_WITH_PICKAXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ctx.get()) + .pattern("AAA") + .pattern("AAA") + .pattern("AAA") + .define('A', ModItems.MAGNET_INGOT) + .unlockedBy("hasitem", RegistrateRecipeProvider.has(ModItems.MAGNET_INGOT)) + .save(provider) + ) + .register(); public static final BlockEntry HOLLOW_MAGNET_BLOCK = REGISTRATE - .block("hollow_magnet_block", HollowMagnetBlock::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .blockstate((ctx, provider) -> { - }) - .simpleItem() - .defaultLoot() - .tag(ModBlockTags.MAGNET, BlockTags.MINEABLE_WITH_PICKAXE) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ctx.get()) - .pattern("AAA") - .pattern("A A") - .pattern("AAA") - .define('A', ModItems.MAGNET_INGOT) - .unlockedBy("hasitem", RegistrateRecipeProvider.has(ModItems.MAGNET_INGOT)) - .save(provider)) - .register(); + .block("hollow_magnet_block", HollowMagnetBlock::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .blockstate((ctx, provider) -> { + }) + .simpleItem() + .defaultLoot() + .tag(ModBlockTags.MAGNET, BlockTags.MINEABLE_WITH_PICKAXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ctx.get()) + .pattern("AAA") + .pattern("A A") + .pattern("AAA") + .define('A', ModItems.MAGNET_INGOT) + .unlockedBy("hasitem", RegistrateRecipeProvider.has(ModItems.MAGNET_INGOT)) + .save(provider)) + .register(); public static final BlockEntry FERRITE_CORE_MAGNET_BLOCK = REGISTRATE - .block("ferrite_core_magnet_block", FerriteCoreMagnetBlock::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .properties(BlockBehaviour.Properties::randomTicks) - .blockstate((ctx, provider) -> { - }) - .simpleItem() - .defaultLoot() - .tag(ModBlockTags.MAGNET, BlockTags.MINEABLE_WITH_PICKAXE) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ctx.get()) - .pattern("AAA") - .pattern("ABA") - .pattern("AAA") - .define('A', ModItems.MAGNET_INGOT) - .define('B', Items.IRON_INGOT) - .unlockedBy("has_magnet_ingot", RegistrateRecipeProvider.has(ModItems.MAGNET_INGOT)) - .unlockedBy("has_iron_ingot", RegistrateRecipeProvider.has(Items.IRON_INGOT)) - .save(provider) - ) - .register(); + .block("ferrite_core_magnet_block", FerriteCoreMagnetBlock::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .properties(BlockBehaviour.Properties::randomTicks) + .blockstate((ctx, provider) -> { + }) + .simpleItem() + .defaultLoot() + .tag(ModBlockTags.MAGNET, BlockTags.MINEABLE_WITH_PICKAXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ctx.get()) + .pattern("AAA") + .pattern("ABA") + .pattern("AAA") + .define('A', ModItems.MAGNET_INGOT) + .define('B', Items.IRON_INGOT) + .unlockedBy("has_magnet_ingot", RegistrateRecipeProvider.has(ModItems.MAGNET_INGOT)) + .unlockedBy("has_iron_ingot", RegistrateRecipeProvider.has(Items.IRON_INGOT)) + .save(provider) + ) + .register(); public static final BlockEntry CHUTE = REGISTRATE - .block("chute", ChuteBlock::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .properties(BlockBehaviour.Properties::noOcclusion) - .blockstate((ctx, provider) -> { - }) - .item(BlockItem::new) - .onRegister(blockItem -> Item.BY_BLOCK.put(ModBlocks.SIMPLE_CHUTE.get(), blockItem)) - .build() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.MINEABLE_WITH_AXE) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModBlocks.CHUTE) - .pattern("A A") - .pattern("ABA") - .pattern(" A ") - .define('A', Items.IRON_INGOT) - .define('B', Items.DROPPER) - .unlockedBy(AnvilCraftDatagen.hasItem(Items.IRON_INGOT), AnvilCraftDatagen.has(Items.IRON_INGOT)) - .unlockedBy(AnvilCraftDatagen.hasItem(Items.DROPPER), AnvilCraftDatagen.has(Items.DROPPER)) - .save(provider) - ) - .register(); + .block("chute", ChuteBlock::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .properties(BlockBehaviour.Properties::noOcclusion) + .blockstate((ctx, provider) -> { + }) + .item(BlockItem::new) + .onRegister(blockItem -> Item.BY_BLOCK.put(ModBlocks.SIMPLE_CHUTE.get(), blockItem)) + .build() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.MINEABLE_WITH_AXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModBlocks.CHUTE) + .pattern("A A") + .pattern("ABA") + .pattern(" A ") + .define('A', Items.IRON_INGOT) + .define('B', Items.DROPPER) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.IRON_INGOT), AnvilCraftDatagen.has(Items.IRON_INGOT)) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.DROPPER), AnvilCraftDatagen.has(Items.DROPPER)) + .save(provider) + ) + .register(); public static final BlockEntry SIMPLE_CHUTE = REGISTRATE - .block("simple_chute", SimpleChuteBlock::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .properties(BlockBehaviour.Properties::noOcclusion) - .blockstate((ctx, provider) -> { - }) - .loot((tables, block) -> tables.dropOther(block, ModBlocks.CHUTE)) - .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.MINEABLE_WITH_AXE) - .register(); + .block("simple_chute", SimpleChuteBlock::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .properties(BlockBehaviour.Properties::noOcclusion) + .blockstate((ctx, provider) -> { + }) + .loot((tables, block) -> tables.dropOther(block, ModBlocks.CHUTE)) + .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.MINEABLE_WITH_AXE) + .register(); public static final BlockEntry AUTO_CRAFTER = REGISTRATE - .block("auto_crafter", AutoCrafterBlock::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .blockstate((ctx, provider) -> { - }) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.MINEABLE_WITH_AXE) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ctx.get()) - .pattern("AAA") - .pattern("ABA") - .pattern("ACA") - .define('A', Items.IRON_INGOT) - .define('B', Items.CRAFTING_TABLE) - .define('C', Items.DROPPER) - .unlockedBy(AnvilCraftDatagen.hasItem(Items.IRON_INGOT), AnvilCraftDatagen.has(Items.IRON_INGOT)) - .unlockedBy(AnvilCraftDatagen.hasItem(Items.CRAFTING_TABLE), - AnvilCraftDatagen.has(Items.CRAFTING_TABLE)) - .unlockedBy(AnvilCraftDatagen.hasItem(Items.DROPPER), AnvilCraftDatagen.has(Items.DROPPER)) - .save(provider) - ) - .register(); + .block("auto_crafter", AutoCrafterBlock::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .blockstate((ctx, provider) -> { + }) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.MINEABLE_WITH_AXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ctx.get()) + .pattern("AAA") + .pattern("ABA") + .pattern("ACA") + .define('A', Items.IRON_INGOT) + .define('B', Items.CRAFTING_TABLE) + .define('C', Items.DROPPER) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.IRON_INGOT), AnvilCraftDatagen.has(Items.IRON_INGOT)) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.CRAFTING_TABLE), + AnvilCraftDatagen.has(Items.CRAFTING_TABLE)) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.DROPPER), AnvilCraftDatagen.has(Items.DROPPER)) + .save(provider) + ) + .register(); public static final BlockEntry ROYAL_GRINDSTONE = REGISTRATE - .block("royal_grindstone", RoyalGrindstone::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .blockstate((ctx, provider) -> { - }) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE) - .register(); + .block("royal_grindstone", RoyalGrindstone::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .blockstate((ctx, provider) -> { + }) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .register(); public static final BlockEntry ROYAL_SMITHING_TABLE = REGISTRATE - .block("royal_smithing_table", RoyalSmithingTableBlock::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .blockstate((ctx, provider) -> { - }) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE) - .register(); + .block("royal_smithing_table", RoyalSmithingTableBlock::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .blockstate((ctx, provider) -> { + }) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .register(); public static final BlockEntry ROYAL_STEEL_BLOCK = REGISTRATE - .block("royal_steel_block", Block::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) - .pattern("AAA") - .pattern("AAA") - .pattern("AAA") - .define('A', ModItems.ROYAL_STEEL_INGOT) - .unlockedBy("hasitem", RegistrateRecipeProvider.has(ModItems.ROYAL_STEEL_INGOT)) - .save(provider) - ) - .register(); + .block("royal_steel_block", Block::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) + .pattern("AAA") + .pattern("AAA") + .pattern("AAA") + .define('A', ModItems.ROYAL_STEEL_INGOT) + .unlockedBy("hasitem", RegistrateRecipeProvider.has(ModItems.ROYAL_STEEL_INGOT)) + .save(provider) + ) + .register(); public static final BlockEntry SMOOTH_ROYAL_STEEL_BLOCK = REGISTRATE - .block("smooth_royal_steel_block", Block::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE) - .register(); + .block("smooth_royal_steel_block", Block::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .register(); public static final BlockEntry CUT_ROYAL_STEEL_BLOCK = REGISTRATE - .block("cut_royal_steel_block", Block::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get(), 4) - .pattern("AA") - .pattern("AA") - .define('A', ModBlocks.ROYAL_STEEL_BLOCK) - .unlockedBy(AnvilCraftDatagen.hasItem(ModBlocks.ROYAL_STEEL_BLOCK.asItem()), - AnvilCraftDatagen.has(ModBlocks.ROYAL_STEEL_BLOCK)) - .save(provider, AnvilCraft.of("craft/cut_royal_steel_block")) - ) - .register(); + .block("cut_royal_steel_block", Block::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get(), 4) + .pattern("AA") + .pattern("AA") + .define('A', ModBlocks.ROYAL_STEEL_BLOCK) + .unlockedBy(AnvilCraftDatagen.hasItem(ModBlocks.ROYAL_STEEL_BLOCK.asItem()), + AnvilCraftDatagen.has(ModBlocks.ROYAL_STEEL_BLOCK)) + .save(provider, AnvilCraft.of("craft/cut_royal_steel_block")) + ) + .register(); public static final BlockEntry CUT_ROYAL_STEEL_SLAB = REGISTRATE - .block("cut_royal_steel_slab", SlabBlock::new) - .initialProperties(() -> Blocks.IRON_BLOCK) - .blockstate((ctx, provider) -> provider.slabBlock(ctx.get(), - AnvilCraft.of("block/cut_royal_steel_block"), - AnvilCraft.of("block/cut_royal_steel_block"))) - .simpleItem() - .loot((tables, block) -> tables.add(block, tables::createSlabItemTable)) - .tag(BlockTags.MINEABLE_WITH_PICKAXE) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get(), 6) - .pattern("AAA") - .define('A', ModBlocks.CUT_ROYAL_STEEL_BLOCK) - .unlockedBy(AnvilCraftDatagen.hasItem(ModBlocks.CUT_ROYAL_STEEL_BLOCK.asItem()), - AnvilCraftDatagen.has(ModBlocks.CUT_ROYAL_STEEL_BLOCK)) - .save(provider, AnvilCraft.of("craft/cut_royal_steel_slab"))) - .register(); + .block("cut_royal_steel_slab", SlabBlock::new) + .initialProperties(() -> Blocks.IRON_BLOCK) + .blockstate((ctx, provider) -> provider.slabBlock(ctx.get(), + AnvilCraft.of("block/cut_royal_steel_block"), + AnvilCraft.of("block/cut_royal_steel_block"))) + .simpleItem() + .loot((tables, block) -> tables.add(block, tables::createSlabItemTable)) + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get(), 6) + .pattern("AAA") + .define('A', ModBlocks.CUT_ROYAL_STEEL_BLOCK) + .unlockedBy(AnvilCraftDatagen.hasItem(ModBlocks.CUT_ROYAL_STEEL_BLOCK.asItem()), + AnvilCraftDatagen.has(ModBlocks.CUT_ROYAL_STEEL_BLOCK)) + .save(provider, AnvilCraft.of("craft/cut_royal_steel_slab"))) + .register(); public static final BlockEntry CUT_ROYAL_STEEL_STAIRS = REGISTRATE - .block("cut_royal_steel_stairs", (properties) -> - new StairBlock(ModBlocks.CUT_ROYAL_STEEL_BLOCK.getDefaultState(), properties)) - .initialProperties(() -> Blocks.IRON_BLOCK) - .blockstate((ctx, provider) -> provider.stairsBlock(ctx.get(), - AnvilCraft.of("block/cut_royal_steel_block"))) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get(), 4) - .pattern("A ") - .pattern("AA ") - .pattern("AAA") - .define('A', ModBlocks.CUT_ROYAL_STEEL_BLOCK) - .unlockedBy(AnvilCraftDatagen.hasItem(ModBlocks.CUT_ROYAL_STEEL_BLOCK.asItem()), - AnvilCraftDatagen.has(ModBlocks.CUT_ROYAL_STEEL_BLOCK)) - .save(provider, AnvilCraft.of("craft/cut_royal_steel_stairs"))) - .register(); + .block("cut_royal_steel_stairs", (properties) -> + new StairBlock(ModBlocks.CUT_ROYAL_STEEL_BLOCK.getDefaultState(), properties)) + .initialProperties(() -> Blocks.IRON_BLOCK) + .blockstate((ctx, provider) -> provider.stairsBlock(ctx.get(), + AnvilCraft.of("block/cut_royal_steel_block"))) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get(), 4) + .pattern("A ") + .pattern("AA ") + .pattern("AAA") + .define('A', ModBlocks.CUT_ROYAL_STEEL_BLOCK) + .unlockedBy(AnvilCraftDatagen.hasItem(ModBlocks.CUT_ROYAL_STEEL_BLOCK.asItem()), + AnvilCraftDatagen.has(ModBlocks.CUT_ROYAL_STEEL_BLOCK)) + .save(provider, AnvilCraft.of("craft/cut_royal_steel_stairs"))) + .register(); public static final BlockEntry LAVA_CAULDRON = REGISTRATE - .block("lava_cauldron", LavaCauldronBlock::new) - .initialProperties(() -> Blocks.LAVA_CAULDRON) - .properties(properties -> properties.lightLevel(blockState -> - blockState.getValue(LayeredCauldronBlock.LEVEL) * 5)) - .blockstate((ctx, provider) -> { - }) - .loot((tables, block) -> tables.dropOther(block, Items.CAULDRON)) - .tag(BlockTags.MINEABLE_WITH_PICKAXE) - .register(); + .block("lava_cauldron", LavaCauldronBlock::new) + .initialProperties(() -> Blocks.LAVA_CAULDRON) + .properties(properties -> properties.lightLevel(blockState -> + blockState.getValue(LayeredCauldronBlock.LEVEL) * 5)) + .blockstate((ctx, provider) -> { + }) + .loot((tables, block) -> tables.dropOther(block, Items.CAULDRON)) + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .register(); public static final BlockEntry CURSED_GOLD_BLOCK = REGISTRATE - .block("cursed_gold_block", Block::new) - .initialProperties(() -> Blocks.GOLD_BLOCK) - .item(CursedBlockItem::new) - .build() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) - .pattern("AAA") - .pattern("AAA") - .pattern("AAA") - .define('A', ModItems.CURSED_GOLD_INGOT) - .unlockedBy(AnvilCraftDatagen.hasItem(ModItems.CURSED_GOLD_INGOT.get()), - AnvilCraftDatagen.has(ModItems.CURSED_GOLD_INGOT)) - .save(provider)) - .register(); + .block("cursed_gold_block", Block::new) + .initialProperties(() -> Blocks.GOLD_BLOCK) + .item(CursedBlockItem::new) + .build() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) + .pattern("AAA") + .pattern("AAA") + .pattern("AAA") + .define('A', ModItems.CURSED_GOLD_INGOT) + .unlockedBy(AnvilCraftDatagen.hasItem(ModItems.CURSED_GOLD_INGOT), + AnvilCraftDatagen.has(ModItems.CURSED_GOLD_INGOT)) + .save(provider)) + .register(); public static final BlockEntry TOPAZ_BLOCK = REGISTRATE - .block("topaz_block", Block::new) - .initialProperties(() -> Blocks.EMERALD_BLOCK) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) - .pattern("AAA") - .pattern("AAA") - .pattern("AAA") - .define('A', ModItems.TOPAZ) - .unlockedBy(AnvilCraftDatagen.hasItem(ModItems.TOPAZ.get()), AnvilCraftDatagen.has(ModItems.TOPAZ)) - .save(provider)) - .register(); + .block("topaz_block", Block::new) + .initialProperties(() -> Blocks.EMERALD_BLOCK) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) + .pattern("AAA") + .pattern("AAA") + .pattern("AAA") + .define('A', ModItems.TOPAZ) + .unlockedBy(AnvilCraftDatagen.hasItem(ModItems.TOPAZ), AnvilCraftDatagen.has(ModItems.TOPAZ)) + .save(provider)) + .register(); public static final BlockEntry RUBY_BLOCK = REGISTRATE - .block("ruby_block", Block::new) - .initialProperties(() -> Blocks.EMERALD_BLOCK) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) - .pattern("AAA") - .pattern("AAA") - .pattern("AAA") - .define('A', ModItems.RUBY) - .unlockedBy(AnvilCraftDatagen.hasItem(ModItems.RUBY.get()), AnvilCraftDatagen.has(ModItems.RUBY)) - .save(provider)) - .register(); + .block("ruby_block", Block::new) + .initialProperties(() -> Blocks.EMERALD_BLOCK) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) + .pattern("AAA") + .pattern("AAA") + .pattern("AAA") + .define('A', ModItems.RUBY) + .unlockedBy(AnvilCraftDatagen.hasItem(ModItems.RUBY), AnvilCraftDatagen.has(ModItems.RUBY)) + .save(provider)) + .register(); public static final BlockEntry SAPPHIRE_BLOCK = REGISTRATE - .block("sapphire_block", Block::new) - .initialProperties(() -> Blocks.EMERALD_BLOCK) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) - .pattern("AAA") - .pattern("AAA") - .pattern("AAA") - .define('A', ModItems.SAPPHIRE) - .unlockedBy(AnvilCraftDatagen.hasItem(ModItems.SAPPHIRE.get()), - AnvilCraftDatagen.has(ModItems.SAPPHIRE)) - .save(provider)) - .register(); + .block("sapphire_block", Block::new) + .initialProperties(() -> Blocks.EMERALD_BLOCK) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE, BlockTags.BEACON_BASE_BLOCKS) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) + .pattern("AAA") + .pattern("AAA") + .pattern("AAA") + .define('A', ModItems.SAPPHIRE) + .unlockedBy(AnvilCraftDatagen.hasItem(ModItems.SAPPHIRE), + AnvilCraftDatagen.has(ModItems.SAPPHIRE)) + .save(provider)) + .register(); public static final BlockEntry RESIN_BLOCK = REGISTRATE - .block("resin_block", SlimeBlock::new) - .initialProperties(() -> Blocks.SLIME_BLOCK) - .blockstate((ctx, provider) -> { - }) - .properties(properties -> properties.sound(SoundType.HONEY_BLOCK)) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) - .pattern("AAA") - .pattern("AAA") - .pattern("AAA") - .define('A', ModItems.RESIN) - .unlockedBy(AnvilCraftDatagen.hasItem(ModItems.RESIN.get()), - AnvilCraftDatagen.has(ModItems.RESIN)) - .save(provider)) - .register(); + .block("resin_block", SlimeBlock::new) + .initialProperties(() -> Blocks.SLIME_BLOCK) + .blockstate((ctx, provider) -> { + }) + .properties(properties -> properties.sound(SoundType.HONEY_BLOCK)) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) + .pattern("AAA") + .pattern("AAA") + .pattern("AAA") + .define('A', ModItems.RESIN) + .unlockedBy(AnvilCraftDatagen.hasItem(ModItems.RESIN), + AnvilCraftDatagen.has(ModItems.RESIN)) + .save(provider)) + .register(); public static final BlockEntry AMBER_BLOCK = REGISTRATE - .block("amber_block", HalfTransparentBlock::new) - .initialProperties(() -> Blocks.EMERALD_BLOCK) - .blockstate((ctx, provider) -> { - provider.simpleBlock(ctx.get()); - provider.models().cubeAll(ctx.getName(), provider.modLoc("block/" + ctx.getName())) - .renderType("translucent"); - }) - .properties(BlockBehaviour.Properties::noOcclusion) - .simpleItem() - .defaultLoot() - .tag(BlockTags.MINEABLE_WITH_PICKAXE) - .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) - .pattern("AAA") - .pattern("AAA") - .pattern("AAA") - .define('A', ModItems.AMBER) - .unlockedBy(AnvilCraftDatagen.hasItem(ModItems.AMBER.get()), AnvilCraftDatagen.has(ModItems.AMBER)) - .save(provider)) - .register(); + .block("amber_block", HalfTransparentBlock::new) + .initialProperties(() -> Blocks.EMERALD_BLOCK) + .blockstate((ctx, provider) -> { + provider.simpleBlock(ctx.get()); + provider.models().cubeAll(ctx.getName(), provider.modLoc("block/" + ctx.getName())) + .renderType("translucent"); + }) + .properties(BlockBehaviour.Properties::noOcclusion) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) + .pattern("AAA") + .pattern("AAA") + .pattern("AAA") + .define('A', ModItems.AMBER) + .unlockedBy(AnvilCraftDatagen.hasItem(ModItems.AMBER), AnvilCraftDatagen.has(ModItems.AMBER)) + .save(provider)) + .register(); + public static final BlockEntry CREATIVE_DYNAMO = REGISTRATE + .block("creative_dynamo", CreativeDynamoBlock::new) + .initialProperties(ModBlocks.MAGNET_BLOCK) + .properties(BlockBehaviour.Properties::noOcclusion) + .blockstate((ctx, provider) -> { + }) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .register(); + public static final BlockEntry HEATER = REGISTRATE + .block("heater", HeaterBlock::new) + .initialProperties(ModBlocks.MAGNET_BLOCK) + .properties(BlockBehaviour.Properties::noOcclusion) + .blockstate((ctx, provider) -> { + }) + .simpleItem() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) + .pattern("ABA") + .pattern("BCB") + .pattern("BBB") + .define('A', Items.TERRACOTTA) + .define('B', Items.IRON_INGOT) + .define('C', ModItemTags.CAPACITOR) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.TERRACOTTA), AnvilCraftDatagen.has(Items.TERRACOTTA)) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.IRON_INGOT), AnvilCraftDatagen.has(Items.IRON_INGOT)) + .unlockedBy(AnvilCraftDatagen.hasItem(ModItemTags.CAPACITOR), AnvilCraftDatagen.has(ModItemTags.CAPACITOR)) + .save(provider)) + .register(); + public static final BlockEntry TRANSMISSION_POLE = REGISTRATE + .block("transmission_pole", TransmissionPoleBlock::new) + .initialProperties(ModBlocks.MAGNET_BLOCK) + .properties(BlockBehaviour.Properties::noOcclusion) + .blockstate((ctx, provider) -> { + }) + .item() + .model((ctx, provider) -> { + }) + .build() + .defaultLoot() + .tag(BlockTags.MINEABLE_WITH_PICKAXE) + .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ctx.get()) + .pattern("A") + .pattern("B") + .pattern("C") + .define('A', ModItems.MAGNETOELECTRIC_CORE) + .define('B', Items.LIGHTNING_ROD) + .define('C', Items.IRON_BLOCK) + .unlockedBy( + AnvilCraftDatagen.hasItem(ModItems.MAGNETOELECTRIC_CORE), + AnvilCraftDatagen.has(ModItems.MAGNETOELECTRIC_CORE) + ) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.LIGHTNING_ROD), AnvilCraftDatagen.has(Items.LIGHTNING_ROD)) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.IRON_BLOCK), AnvilCraftDatagen.has(Items.IRON_BLOCK)) + .save(provider)) + .register(); public static void register() { } 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 b9c0be769..e17f23f37 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemGroups.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemGroups.java @@ -50,6 +50,8 @@ public class ModItemGroups { entries.accept(ModItems.COCOA_LIQUOR.get().getDefaultInstance()); entries.accept(ModItems.COCOA_BUTTER.get().getDefaultInstance()); entries.accept(ModItems.COCOA_POWDER.get().getDefaultInstance()); + entries.accept(ModItems.CAPACITOR.get().getDefaultInstance()); + entries.accept(ModItems.CAPACITOR_EMPTY.get().getDefaultInstance()); }) .build() ) @@ -70,6 +72,9 @@ public class ModItemGroups { entries.accept(ModBlocks.ROYAL_ANVIL.asStack()); entries.accept(ModBlocks.ROYAL_GRINDSTONE.asStack()); entries.accept(ModBlocks.ROYAL_SMITHING_TABLE.asStack()); + entries.accept(ModBlocks.CREATIVE_DYNAMO.asStack()); + entries.accept(ModBlocks.HEATER.asStack()); + entries.accept(ModBlocks.TRANSMISSION_POLE.asStack()); entries.accept(ModBlocks.MAGNET_BLOCK.asStack()); entries.accept(ModBlocks.HOLLOW_MAGNET_BLOCK.asStack()); entries.accept(ModBlocks.FERRITE_CORE_MAGNET_BLOCK.asStack()); diff --git a/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemTags.java b/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemTags.java index 2be560ef1..699fc0647 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemTags.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModItemTags.java @@ -22,18 +22,14 @@ public class ModItemTags { public static final TagKey PLATES = bindC("plates"); public static final TagKey GOLD_PLATES = bindC("gold_plates"); public static final TagKey IRON_PLATES = bindC("iron_plates"); - public static final TagKey ROYAL_STEEL_PICKAXE_BASE = bindMod("royal_steel_pickaxe_base"); + public static final TagKey ROYAL_STEEL_PICKAXE_BASE = bind("royal_steel_pickaxe_base"); + public static final TagKey CAPACITOR = bind("capacitor"); private static @NotNull TagKey bindC(String id) { return TagKey.create(Registries.ITEM, new ResourceLocation("c", id)); } - @SuppressWarnings("SameParameterValue") - private static @NotNull TagKey bindMod(String id) { - return TagKey.create(Registries.ITEM, new ResourceLocation("anvilcraft", id)); - } - private static @NotNull TagKey bind(String id) { return TagKey.create(Registries.ITEM, AnvilCraft.of(id)); } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/init/ModItems.java b/common/src/main/java/dev/dubhe/anvilcraft/init/ModItems.java index 2d4fbaad1..b2599eace 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModItems.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModItems.java @@ -6,6 +6,7 @@ import dev.dubhe.anvilcraft.data.generator.AnvilCraftDatagen; import dev.dubhe.anvilcraft.data.recipe.crafting.ShapedTagRecipeBuilder; import dev.dubhe.anvilcraft.item.AnvilHammerItem; +import dev.dubhe.anvilcraft.item.CapacitorItem; import dev.dubhe.anvilcraft.item.CursedItem; import dev.dubhe.anvilcraft.item.GeodeItem; import dev.dubhe.anvilcraft.item.MagnetItem; @@ -461,8 +462,31 @@ public void appendHoverText( public static final ItemEntry SEA_HEART_SHELL_SHARD = REGISTRATE .item("sea_heart_shell_shard", Item::new) .register(); + public static final ItemEntry CAPACITOR = REGISTRATE + .item("capacitor", CapacitorItem::new) + .tag(ModItemTags.CAPACITOR) + .register(); + public static final ItemEntry MAGNETOELECTRIC_CORE = REGISTRATE + .item("magnetoelectric_core", Item::new) + .register(); + public static final ItemEntry CAPACITOR_EMPTY = REGISTRATE + .item("capacitor_empty", CapacitorItem::new) + .tag(ModItemTags.CAPACITOR) + .recipe((ctx, provider) -> ShapedTagRecipeBuilder.shaped(RecipeCategory.TOOLS, ctx.get().getDefaultInstance()) + .pattern("ABA") + .pattern("ACA") + .pattern("ABA") + .define('A', Items.IRON_INGOT) + .define('B', Items.COPPER_INGOT) + .define('C', Items.TERRACOTTA) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.IRON_INGOT), RegistrateRecipeProvider.has(Items.IRON_INGOT)) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.COPPER_INGOT), RegistrateRecipeProvider.has(Items.COPPER_INGOT)) + .unlockedBy(AnvilCraftDatagen.hasItem(Items.TERRACOTTA), RegistrateRecipeProvider.has(Items.TERRACOTTA)) + .save(provider)) + .register(); public static final ItemEntry ANVIL_HAMMER = REGISTRATE - .item("anvil_hammer", properties -> new AnvilHammerItem(properties.durability(35))) + .item("anvil_hammer", AnvilHammerItem::new) + .properties(properties -> properties.durability(35)) .model((ctx, provider) -> { }) .recipe((ctx, provider) -> ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ctx.get()) @@ -473,7 +497,7 @@ public void appendHoverText( .define('B', Items.LIGHTNING_ROD) .define('C', Items.IRON_INGOT) .unlockedBy(AnvilCraftDatagen.hasItem(Items.ANVIL), RegistrateRecipeProvider.has(Items.ANVIL)) - .unlockedBy(AnvilCraftDatagen.hasItem(Items.LIGHTNING_ROD), + .unlockedBy(AnvilCraftDatagen.hasItem(Items.LIGHTNING_ROD), RegistrateRecipeProvider.has(Items.LIGHTNING_ROD)) .unlockedBy(AnvilCraftDatagen.hasItem(Items.IRON_INGOT), RegistrateRecipeProvider.has(Items.IRON_INGOT)) .save(provider)) diff --git a/common/src/main/java/dev/dubhe/anvilcraft/init/ModMenuTypes.java b/common/src/main/java/dev/dubhe/anvilcraft/init/ModMenuTypes.java index 39667e376..19ec035d6 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModMenuTypes.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModMenuTypes.java @@ -7,11 +7,13 @@ import dev.dubhe.anvilcraft.client.gui.screen.inventory.RoyalAnvilScreen; import dev.dubhe.anvilcraft.client.gui.screen.inventory.RoyalGrindstoneScreen; import dev.dubhe.anvilcraft.client.gui.screen.inventory.RoyalSmithingScreen; +import dev.dubhe.anvilcraft.client.gui.screen.inventory.SliderScreen; import dev.dubhe.anvilcraft.inventory.AutoCrafterMenu; import dev.dubhe.anvilcraft.inventory.ChuteMenu; import dev.dubhe.anvilcraft.inventory.RoyalAnvilMenu; import dev.dubhe.anvilcraft.inventory.RoyalGrindstoneMenu; import dev.dubhe.anvilcraft.inventory.RoyalSmithingMenu; +import dev.dubhe.anvilcraft.inventory.SliderMenu; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.MenuProvider; @@ -28,17 +30,33 @@ public class ModMenuTypes { .menu("chute", ChuteMenu::new, () -> ChuteScreen::new) .register(); public static final MenuEntry ROYAL_GRINDSTONE = REGISTRATE - .menu("royal_grindstone", (type, id, inventory) -> - new RoyalGrindstoneMenu(type, id, inventory), () -> RoyalGrindstoneScreen::new) + .menu( + "royal_grindstone", + (type, id, inv) -> new RoyalGrindstoneMenu(type, id, inv), + () -> RoyalGrindstoneScreen::new + ) .register(); public static final MenuEntry ROYAL_ANVIL = REGISTRATE - .menu("royal_anvil", (type, id, inventory) -> - new RoyalAnvilMenu(id, inventory), () -> RoyalAnvilScreen::new) + .menu( + "royal_anvil", + (type, id, inv) -> new RoyalAnvilMenu(id, inv), + () -> RoyalAnvilScreen::new + ) .register(); public static final MenuEntry ROYAL_SMITHING = REGISTRATE - .menu("royal_smithing_table", (type, id, inventory) -> - new RoyalSmithingMenu(type, id, inventory), () -> RoyalSmithingScreen::new) + .menu( + "royal_smithing_table", + (type, id, inv) -> new RoyalSmithingMenu(type, id, inv), + () -> RoyalSmithingScreen::new + ) .register(); + public static final MenuEntry SLIDER = REGISTRATE + .menu( + "slider", + (menuType, containerId, inventory) -> new SliderMenu(menuType, containerId), + () -> SliderScreen::new + ) + .register(); public static void register() { } 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 718fea6e2..06671e151 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/init/ModNetworks.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/init/ModNetworks.java @@ -2,8 +2,10 @@ import dev.dubhe.anvilcraft.AnvilCraft; import dev.dubhe.anvilcraft.api.network.Network; -import dev.dubhe.anvilcraft.network.MachineOutputDirectionPack; import dev.dubhe.anvilcraft.network.MachineEnableFilterPack; +import dev.dubhe.anvilcraft.network.MachineOutputDirectionPack; +import dev.dubhe.anvilcraft.network.SliderInitPack; +import dev.dubhe.anvilcraft.network.SliderUpdatePack; import dev.dubhe.anvilcraft.network.SlotDisableChangePack; import dev.dubhe.anvilcraft.network.SlotFilterChangePack; import net.minecraft.resources.ResourceLocation; @@ -21,6 +23,12 @@ public class ModNetworks { public static final ResourceLocation SLOT_FILTER_CHANGE_PACKET = Network .register(AnvilCraft.of("slot_filter_change"), SlotFilterChangePack.class, SlotFilterChangePack::new); + public static final ResourceLocation SLIDER_UPDATE = Network + .register(AnvilCraft.of("slider_update"), + SliderUpdatePack.class, SliderUpdatePack::new); + public static final ResourceLocation SLIDER_INIT = Network + .register(AnvilCraft.of("slider_init"), + SliderInitPack.class, SliderInitPack::new); public static void register() { } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/inventory/RoyalAnvilMenu.java b/common/src/main/java/dev/dubhe/anvilcraft/inventory/RoyalAnvilMenu.java index 845df84aa..0418bd3c2 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/inventory/RoyalAnvilMenu.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/inventory/RoyalAnvilMenu.java @@ -1,7 +1,7 @@ package dev.dubhe.anvilcraft.inventory; import dev.dubhe.anvilcraft.init.ModMenuTypes; -import dev.dubhe.anvilcraft.item.Cursed; +import dev.dubhe.anvilcraft.item.ICursed; import net.minecraft.Util; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.EntityType; @@ -161,7 +161,7 @@ protected void onTake(@NotNull Player player, @NotNull ItemStack stack) { super.onTake(player, stack); Level level = player.level(); if (level.isClientSide()) return; - int curedNumber = Cursed.hasCuredNumber(player); + int curedNumber = ICursed.hasCuredNumber(player); if (curedNumber <= 0) return; LightningBolt bolt = new LightningBolt(EntityType.LIGHTNING_BOLT, level); bolt.setPos(player.getX(), player.getY(), player.getZ()); diff --git a/common/src/main/java/dev/dubhe/anvilcraft/inventory/SliderMenu.java b/common/src/main/java/dev/dubhe/anvilcraft/inventory/SliderMenu.java new file mode 100644 index 000000000..5c214ffcc --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/inventory/SliderMenu.java @@ -0,0 +1,60 @@ +package dev.dubhe.anvilcraft.inventory; + +import dev.dubhe.anvilcraft.init.ModMenuTypes; +import lombok.Getter; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +@Getter +public class SliderMenu extends AbstractContainerMenu { + private final int min; + private final int max; + private final Update update; + + /** + * @param menuType 菜单类型 + * @param containerId 容器ID + */ + public SliderMenu(@Nullable MenuType menuType, int containerId) { + super(menuType, containerId); + this.min = 0; + this.max = 160; + this.update = null; + } + + /** + * @param containerId 容器ID + * @param update 更新回调 + */ + public SliderMenu(int containerId, int min, int max, Update update) { + super(ModMenuTypes.SLIDER.get(), containerId); + this.min = min; + this.max = max; + this.update = update; + } + + @Override + public @NotNull ItemStack quickMoveStack(@NotNull Player player, int index) { + Slot sourceSlot = slots.get(index); + //noinspection ConstantValue + if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; + return sourceSlot.getItem(); + } + + @Override + public boolean stillValid(@NotNull Player player) { + return true; + } + + /** + * 滑条回调 + */ + public interface Update { + void update(int value); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/item/AnvilHammerItem.java b/common/src/main/java/dev/dubhe/anvilcraft/item/AnvilHammerItem.java index d6b6af927..5f250f546 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/item/AnvilHammerItem.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/item/AnvilHammerItem.java @@ -20,6 +20,7 @@ import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.item.FallingBlockEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Equipable; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Vanishable; @@ -29,7 +30,7 @@ import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.NotNull; -public class AnvilHammerItem extends Item implements Vanishable { +public class AnvilHammerItem extends Item implements Vanishable, Equipable { private long lastDropAnvilTime = 0; private final Multimap defaultModifiers; @@ -168,4 +169,9 @@ public boolean isCorrectToolForDrops(@NotNull BlockState block) { } return super.getDefaultAttributeModifiers(slot); } + + @Override + public @NotNull EquipmentSlot getEquipmentSlot() { + return EquipmentSlot.HEAD; + } } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/item/CapacitorItem.java b/common/src/main/java/dev/dubhe/anvilcraft/item/CapacitorItem.java new file mode 100644 index 000000000..9f92250f7 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/item/CapacitorItem.java @@ -0,0 +1,9 @@ +package dev.dubhe.anvilcraft.item; + +import net.minecraft.world.item.Item; + +public class CapacitorItem extends Item { + public CapacitorItem(Properties properties) { + super(properties); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/item/CursedBlockItem.java b/common/src/main/java/dev/dubhe/anvilcraft/item/CursedBlockItem.java index c8b82e0b3..ae638b752 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/item/CursedBlockItem.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/item/CursedBlockItem.java @@ -6,7 +6,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; -public class CursedBlockItem extends BlockItem implements Cursed { +public class CursedBlockItem extends BlockItem implements ICursed { public CursedBlockItem(Block block, Properties properties) { super(block, properties); @@ -15,6 +15,6 @@ public CursedBlockItem(Block block, Properties properties) { @Override public void inventoryTick(ItemStack stack, Level level, Entity entity, int slotId, boolean isSelected) { super.inventoryTick(stack, level, entity, slotId, isSelected); - Cursed.super.inventoryTick(stack, level, entity, slotId, isSelected); + ICursed.super.inventoryTick(stack, level, entity, slotId, isSelected); } } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/item/CursedItem.java b/common/src/main/java/dev/dubhe/anvilcraft/item/CursedItem.java index 380c6cd25..6461cbcc0 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/item/CursedItem.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/item/CursedItem.java @@ -4,15 +4,18 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; -public class CursedItem extends Item implements Cursed { +public class CursedItem extends Item implements ICursed { public CursedItem(Properties properties) { super(properties); } @Override - public void inventoryTick(ItemStack stack, Level level, Entity entity, int slotId, boolean isSelected) { + public void inventoryTick( + @NotNull ItemStack stack, @NotNull Level level, @NotNull Entity entity, int slotId, boolean isSelected + ) { super.inventoryTick(stack, level, entity, slotId, isSelected); - Cursed.super.inventoryTick(stack, level, entity, slotId, isSelected); + ICursed.super.inventoryTick(stack, level, entity, slotId, isSelected); } } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/item/Cursed.java b/common/src/main/java/dev/dubhe/anvilcraft/item/ICursed.java similarity index 92% rename from common/src/main/java/dev/dubhe/anvilcraft/item/Cursed.java rename to common/src/main/java/dev/dubhe/anvilcraft/item/ICursed.java index d1da7cbae..d936b0add 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/item/Cursed.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/item/ICursed.java @@ -12,7 +12,7 @@ /** * 诅咒物品 */ -public interface Cursed { +public interface ICursed { /** * 执行效果 * @@ -29,7 +29,7 @@ default void inventoryTick(ItemStack stack, Level level, Entity entity, int slot MobEffectInstance slowness = new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 200, 1, false, true); MobEffectInstance hungry = new MobEffectInstance(MobEffects.HUNGER, 200, 1, false, true); player.addEffect((weakness)); - int curedNumber = Cursed.hasCuredNumber(player); + int curedNumber = ICursed.hasCuredNumber(player); if (curedNumber > 8) { player.addEffect((slowness)); } @@ -49,7 +49,7 @@ static int hasCuredNumber(@NotNull Player player) { int i = 0; for (int j = 0; j < inventory.getContainerSize(); ++j) { ItemStack itemStack = inventory.getItem(j); - if (!(itemStack.getItem() instanceof Cursed)) continue; + if (!(itemStack.getItem() instanceof ICursed)) continue; i += itemStack.getCount(); } return i; diff --git a/common/src/main/java/dev/dubhe/anvilcraft/item/RoyalUpgradeTemplateItem.java b/common/src/main/java/dev/dubhe/anvilcraft/item/RoyalUpgradeTemplateItem.java index c17474fce..90512534e 100644 --- a/common/src/main/java/dev/dubhe/anvilcraft/item/RoyalUpgradeTemplateItem.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/item/RoyalUpgradeTemplateItem.java @@ -4,6 +4,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.SmithingTemplateItem; +import org.jetbrains.annotations.NotNull; import java.util.List; @@ -31,4 +32,9 @@ public RoyalUpgradeTemplateItem(@SuppressWarnings("unused") Properties propertie super(APPLIES_TO, UPGRADE_INGREDIENTS, UPGRADE, UPGRADE_BASE_SLOT_DESCRIPTION, UPGRADE_ADDITIONS_SLOT_DESCRIPTION, List.of(EMPTY_SLOT_PICKAXE), List.of(EMPTY_SLOT_INGOT)); } + + @Override + public @NotNull String getDescriptionId() { + return this.getOrCreateDescriptionId(); + } } diff --git a/common/src/main/java/dev/dubhe/anvilcraft/mixin/LevelRendererMixin.java b/common/src/main/java/dev/dubhe/anvilcraft/mixin/LevelRendererMixin.java new file mode 100644 index 000000000..8bf381777 --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/mixin/LevelRendererMixin.java @@ -0,0 +1,69 @@ +package dev.dubhe.anvilcraft.mixin; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import dev.dubhe.anvilcraft.client.renderer.PowerGridRenderer; +import dev.dubhe.anvilcraft.init.ModItems; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.Camera; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderBuffers; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; +import org.joml.Matrix4f; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +@Mixin(LevelRenderer.class) +@Environment(EnvType.CLIENT) +public abstract class LevelRendererMixin { + @Shadow + @Final + private RenderBuffers renderBuffers; + + @Inject( + method = "renderLevel", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/renderer/debug/DebugRenderer;render(Lcom/mojang/blaze3d/vertex/PoseStack;" + + "Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;DDD)V" + ), + locals = LocalCapture.CAPTURE_FAILEXCEPTION + ) + private void renderLevel( + PoseStack poseStack, float partialTick, long finishNanoTime, + boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, + LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci, + @NotNull ProfilerFiller profilerFiller, @NotNull Vec3 vec3 + ) { + Entity entity = camera.getEntity(); + boolean bl = true; + for (ItemStack slot : entity.getArmorSlots()) { + if (slot.is(ModItems.ANVIL_HAMMER.get())) { + bl = false; + break; + } + } + if (bl) return; + MultiBufferSource.BufferSource bufferSource = this.renderBuffers.bufferSource(); + VertexConsumer vertexConsumer3 = bufferSource.getBuffer(RenderType.lines()); + double camX = vec3.x(); + double camY = vec3.y(); + double camZ = vec3.z(); + profilerFiller.popPush("grid"); + PowerGridRenderer.render(poseStack, vertexConsumer3, camX, camY, camZ); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/network/SliderInitPack.java b/common/src/main/java/dev/dubhe/anvilcraft/network/SliderInitPack.java new file mode 100644 index 000000000..04726549e --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/network/SliderInitPack.java @@ -0,0 +1,61 @@ +package dev.dubhe.anvilcraft.network; + +import dev.dubhe.anvilcraft.api.network.Packet; +import dev.dubhe.anvilcraft.client.gui.screen.inventory.SliderScreen; +import dev.dubhe.anvilcraft.init.ModNetworks; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.Minecraft; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; + +public class SliderInitPack implements Packet { + private final int value; + private final int min; + private final int max; + + /** + * @param value 当前值 + * @param min 最小值 + * @param max 最大值 + */ + public SliderInitPack(int value, int min, int max) { + this.value = value; + this.min = min; + this.max = max; + } + + /** + * @param buf 缓冲区 + */ + public SliderInitPack(@NotNull FriendlyByteBuf buf) { + this.value = buf.readInt(); + this.min = buf.readInt(); + this.max = buf.readInt(); + } + + @Override + public ResourceLocation getType() { + return ModNetworks.SLIDER_INIT; + } + + @Override + public void encode(@NotNull FriendlyByteBuf buf) { + buf.writeInt(this.value); + buf.writeInt(this.min); + buf.writeInt(this.max); + } + + @Override + @Environment(EnvType.CLIENT) + public void handler() { + Minecraft client = Minecraft.getInstance(); + client.execute(() -> { + if (!(client.screen instanceof SliderScreen screen)) return; + screen.setMin(this.min); + screen.setMax(this.max); + screen.setValue(this.value); + }); + } +} diff --git a/common/src/main/java/dev/dubhe/anvilcraft/network/SliderUpdatePack.java b/common/src/main/java/dev/dubhe/anvilcraft/network/SliderUpdatePack.java new file mode 100644 index 000000000..c46e2f20f --- /dev/null +++ b/common/src/main/java/dev/dubhe/anvilcraft/network/SliderUpdatePack.java @@ -0,0 +1,42 @@ +package dev.dubhe.anvilcraft.network; + +import dev.dubhe.anvilcraft.api.network.Packet; +import dev.dubhe.anvilcraft.init.ModNetworks; +import dev.dubhe.anvilcraft.inventory.SliderMenu; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.NotNull; + +public class SliderUpdatePack implements Packet { + private final int value; + + public SliderUpdatePack(int value) { + this.value = value; + } + + public SliderUpdatePack(@NotNull FriendlyByteBuf buf) { + this.value = buf.readInt(); + } + + @Override + public ResourceLocation getType() { + return ModNetworks.SLIDER_UPDATE; + } + + @Override + public void encode(@NotNull FriendlyByteBuf buf) { + buf.writeInt(this.value); + } + + @Override + public void handler(@NotNull MinecraftServer server, ServerPlayer player) { + server.execute(() -> { + if (!player.hasContainerOpen()) return; + if (!(player.containerMenu instanceof SliderMenu menu)) return; + SliderMenu.Update update = menu.getUpdate(); + if (update != null) update.update(value); + }); + } +} diff --git a/common/src/main/resources/anvilcraft-common.mixins.json b/common/src/main/resources/anvilcraft-common.mixins.json index 9fc891070..3214ddeb3 100644 --- a/common/src/main/resources/anvilcraft-common.mixins.json +++ b/common/src/main/resources/anvilcraft-common.mixins.json @@ -17,6 +17,7 @@ "SolidBucketItemMixin" ], "client": [ + "LevelRendererMixin" ], "injectors": { "defaultRequire": 1 diff --git a/common/src/main/resources/assets/anvilcraft/blockstates/creative_dynamo.json b/common/src/main/resources/assets/anvilcraft/blockstates/creative_dynamo.json new file mode 100644 index 000000000..e4e2dcaae --- /dev/null +++ b/common/src/main/resources/assets/anvilcraft/blockstates/creative_dynamo.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "anvilcraft:block/creative_dynamo" + } + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/anvilcraft/blockstates/heater.json b/common/src/main/resources/assets/anvilcraft/blockstates/heater.json new file mode 100644 index 000000000..170350ba1 --- /dev/null +++ b/common/src/main/resources/assets/anvilcraft/blockstates/heater.json @@ -0,0 +1,10 @@ +{ + "variants": { + "lit=false": { + "model": "anvilcraft:block/heater" + }, + "lit=true": { + "model": "anvilcraft:block/heater_lit" + } + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/anvilcraft/blockstates/transmission_pole.json b/common/src/main/resources/assets/anvilcraft/blockstates/transmission_pole.json new file mode 100644 index 000000000..192787d4b --- /dev/null +++ b/common/src/main/resources/assets/anvilcraft/blockstates/transmission_pole.json @@ -0,0 +1,13 @@ +{ + "variants": { + "half=bottom": { + "model": "anvilcraft:block/transmission_pole_base" + }, + "half=mid": { + "model": "anvilcraft:block/transmission_pole_mid" + }, + "half=top": { + "model": "anvilcraft:block/transmission_pole_top" + } + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/anvilcraft/lang/es_es.json b/common/src/main/resources/assets/anvilcraft/lang/es_es.json index f3e00b72b..af01c3399 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/es_es.json +++ b/common/src/main/resources/assets/anvilcraft/lang/es_es.json @@ -70,7 +70,7 @@ "item.anvilcraft.topaz": "Topacio", "item.anvilcraft.utusan": "Polvo Wudu", "item.anvilcraft.utusan_raw": "Polvo Wudu crudo", - "item.minecraft.smithing_template": "Plantilla de mejora de acero real", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "Plantilla de mejora de acero real", "itemGroup.anvilcraft.block": "Artesanía de yunque - Bloque", "itemGroup.anvilcraft.item": "Artesanía de yunque - Ítem", "screen.anvilcraft.button.direction": "Dirección de salida: %s", diff --git a/common/src/main/resources/assets/anvilcraft/lang/fr_fr.json b/common/src/main/resources/assets/anvilcraft/lang/fr_fr.json index 72e38a006..e0d8646e7 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/fr_fr.json +++ b/common/src/main/resources/assets/anvilcraft/lang/fr_fr.json @@ -70,7 +70,7 @@ "item.anvilcraft.topaz": "Topaze", "item.anvilcraft.utusan": "Poudre wudu", "item.anvilcraft.utusan_raw": "Poudre wudu (cru)", - "item.minecraft.smithing_template": "Modèle de forge d'acier royal", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "Modèle de forge d'acier royal", "itemGroup.anvilcraft.block": "Artisanat d'enclume - Blocs", "itemGroup.anvilcraft.item": "Artisanat d'enclume - Objet", "screen.anvilcraft.button.direction": "Output Direction: %s", diff --git a/common/src/main/resources/assets/anvilcraft/lang/ja_jp.json b/common/src/main/resources/assets/anvilcraft/lang/ja_jp.json index 876f28d47..ee6b09515 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/ja_jp.json +++ b/common/src/main/resources/assets/anvilcraft/lang/ja_jp.json @@ -70,7 +70,7 @@ "item.anvilcraft.topaz": "トパーズ", "item.anvilcraft.utusan": "ウドゥパウダー", "item.anvilcraft.utusan_raw": "ウードゥーパウダー(生)", - "item.minecraft.smithing_template": "王室鋼の鍛冶型", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "王室鋼の鍛冶型", "itemGroup.anvilcraft.block": "金床工芸 - ブロック", "itemGroup.anvilcraft.item": "金床工芸 - アイテム", "screen.anvilcraft.button.direction": "出力方向:%s", diff --git a/common/src/main/resources/assets/anvilcraft/lang/ko_kr.json b/common/src/main/resources/assets/anvilcraft/lang/ko_kr.json index 811eb1610..5667a6285 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/ko_kr.json +++ b/common/src/main/resources/assets/anvilcraft/lang/ko_kr.json @@ -70,7 +70,7 @@ "item.anvilcraft.topaz": "황옥", "item.anvilcraft.utusan": "오독가루", "item.anvilcraft.utusan_raw": "오독가루 (생)", - "item.minecraft.smithing_template": "로얄 스틸 단조 거푸집 공사", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "로얄 스틸 단조 거푸집 공사", "itemGroup.anvilcraft.block": "모루 공예 - 블록", "itemGroup.anvilcraft.item": "모루 공예 - 물건", "screen.anvilcraft.button.direction": "출력 방향: %s", diff --git a/common/src/main/resources/assets/anvilcraft/lang/lzh.json b/common/src/main/resources/assets/anvilcraft/lang/lzh.json index 8f0564be8..814ca45f9 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/lzh.json +++ b/common/src/main/resources/assets/anvilcraft/lang/lzh.json @@ -70,7 +70,7 @@ "item.anvilcraft.topaz": "黃玉", "item.anvilcraft.utusan": "五毒散", "item.anvilcraft.utusan_raw": "五毒散(生)", - "item.minecraft.smithing_template": "皇家鋼鍛模", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "皇家鋼鍛模", "itemGroup.anvilcraft.block": "鐵砧匠藝 - 塊", "itemGroup.anvilcraft.item": "鐵砧匠藝 - 物", "screen.anvilcraft.button.direction": "趋之向:%s", diff --git a/common/src/main/resources/assets/anvilcraft/lang/ru_ru.json b/common/src/main/resources/assets/anvilcraft/lang/ru_ru.json index b33c95588..9dfa27694 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/ru_ru.json +++ b/common/src/main/resources/assets/anvilcraft/lang/ru_ru.json @@ -70,7 +70,7 @@ "item.anvilcraft.topaz": "Topaz", "item.anvilcraft.utusan": "Порошок У Ду", "item.anvilcraft.utusan_raw": "Порошок У Ду (сырой)", - "item.minecraft.smithing_template": "Шаблон улучшения королевской стали", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "Шаблон улучшения королевской стали", "itemGroup.anvilcraft.block": "Anvilcraft — Блок", "itemGroup.anvilcraft.item": "Anvilcraft — Предмет", "screen.anvilcraft.button.direction": "Направление вывода: %s", diff --git a/common/src/main/resources/assets/anvilcraft/lang/zh_cn.json b/common/src/main/resources/assets/anvilcraft/lang/zh_cn.json index b73854aca..fc606eaf3 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/zh_cn.json +++ b/common/src/main/resources/assets/anvilcraft/lang/zh_cn.json @@ -70,7 +70,7 @@ "item.anvilcraft.topaz": "黄玉", "item.anvilcraft.utusan": "五毒散", "item.anvilcraft.utusan_raw": "五毒散(生)", - "item.minecraft.smithing_template": "皇家钢锻造模板", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "皇家钢锻造模板", "itemGroup.anvilcraft.block": "铁砧工艺 - 方块", "itemGroup.anvilcraft.item": "铁砧工艺 - 物品", "screen.anvilcraft.button.direction": "输出方向:%s", diff --git a/common/src/main/resources/assets/anvilcraft/lang/zh_hk.json b/common/src/main/resources/assets/anvilcraft/lang/zh_hk.json index 8ba74c355..516dc861a 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/zh_hk.json +++ b/common/src/main/resources/assets/anvilcraft/lang/zh_hk.json @@ -70,7 +70,7 @@ "item.anvilcraft.topaz": "黃玉", "item.anvilcraft.utusan": "五毒散", "item.anvilcraft.utusan_raw": "五毒散(生)", - "item.minecraft.smithing_template": "皇家鋼鍛造模板", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "皇家鋼鍛造模板", "itemGroup.anvilcraft.block": "鐵砧工藝 - 方塊", "itemGroup.anvilcraft.item": "鐵砧工藝 - 物品", "screen.anvilcraft.button.direction": "輸出方向:%s", diff --git a/common/src/main/resources/assets/anvilcraft/lang/zh_tw.json b/common/src/main/resources/assets/anvilcraft/lang/zh_tw.json index 7dbfd7704..c181a5246 100644 --- a/common/src/main/resources/assets/anvilcraft/lang/zh_tw.json +++ b/common/src/main/resources/assets/anvilcraft/lang/zh_tw.json @@ -70,7 +70,7 @@ "item.anvilcraft.topaz": "黃玉", "item.anvilcraft.utusan": "五毒散", "item.anvilcraft.utusan_raw": "五毒散(生)", - "item.minecraft.smithing_template": "皇家鍛造模板", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "皇家鍛造模板", "itemGroup.anvilcraft.block": "鐵砧工藝 - 方塊", "itemGroup.anvilcraft.item": "鐵砧工藝 - 物品", "screen.anvilcraft.button.direction": "輸出方向:%s", diff --git a/common/src/main/resources/assets/anvilcraft/models/block/heater.json b/common/src/main/resources/assets/anvilcraft/models/block/heater.json index a4029dc2b..a888db904 100644 --- a/common/src/main/resources/assets/anvilcraft/models/block/heater.json +++ b/common/src/main/resources/assets/anvilcraft/models/block/heater.json @@ -1,5 +1,7 @@ { "credit": "Made by XeKr with Blockbench", + "parent": "minecraft:block/block", + "render_type": "minecraft:translucent", "ambientocclusion": false, "textures": { "particle": "anvilcraft:block/heater", diff --git a/common/src/main/resources/assets/anvilcraft/models/block/heater_lit.json b/common/src/main/resources/assets/anvilcraft/models/block/heater_lit.json index 891281c7f..c67050cc1 100644 --- a/common/src/main/resources/assets/anvilcraft/models/block/heater_lit.json +++ b/common/src/main/resources/assets/anvilcraft/models/block/heater_lit.json @@ -1,5 +1,7 @@ { "credit": "Made by XeKr with Blockbench", + "parent": "minecraft:block/block", + "render_type": "minecraft:translucent", "ambientocclusion": false, "textures": { "particle": "anvilcraft:block/heater_lit", diff --git a/common/src/main/resources/assets/anvilcraft/models/item/transmission_pole.json b/common/src/main/resources/assets/anvilcraft/models/item/transmission_pole.json new file mode 100644 index 000000000..7bed1e652 --- /dev/null +++ b/common/src/main/resources/assets/anvilcraft/models/item/transmission_pole.json @@ -0,0 +1,3 @@ +{ + "parent": "anvilcraft:block/transmission_pole_overall" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/auto_crafter.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/background/auto_crafter.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/auto_crafter.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/background/auto_crafter.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/chute.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/background/chute.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/chute.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/background/chute.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/button_d.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_d.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/button_d.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_d.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/button_e.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_e.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/button_e.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_e.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/button_n.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_n.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/button_n.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_n.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/button_no.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_no.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/button_no.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_no.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/button_s.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_s.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/button_s.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_s.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/button_u.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_u.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/button_u.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_u.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/button_w.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_w.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/button_w.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_w.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/button_yes.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_yes.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/button_yes.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/button_yes.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/disabled_slot.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/disabled_slot.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/disabled_slot.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/machine/disabled_slot.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/slider.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/slider/background.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/slider.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/slider/background.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/slider_button_add.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/slider/button_add.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/slider_button_add.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/slider/button_add.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/slider_button_max.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/slider/button_max.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/slider_button_max.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/slider/button_max.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/slider_button_min.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/slider/button_min.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/slider_button_min.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/slider/button_min.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/slider_button_minus.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/slider/button_minus.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/slider_button_minus.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/slider/button_minus.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/slider_slider.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/slider/slider.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/slider_slider.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/slider/slider.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/royal_anvil.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/smithing/background/royal_anvil.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/royal_anvil.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/smithing/background/royal_anvil.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/royal_grindstone.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/smithing/background/royal_grindstone.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/royal_grindstone.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/smithing/background/royal_grindstone.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/royal_smithing_table.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/smithing/background/royal_smithing_table.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/royal_smithing_table.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/smithing/background/royal_smithing_table.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/error.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/smithing/error.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/error.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/smithing/error.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/text_field.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/smithing/text_field.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/text_field.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/smithing/text_field.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/text_field_disabled.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/smithing/text_field_disabled.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/gui/container/text_field_disabled.png rename to common/src/main/resources/assets/anvilcraft/textures/gui/container/smithing/text_field_disabled.png diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/warning_material.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/warning_material.png deleted file mode 100644 index da98667a3..000000000 Binary files a/common/src/main/resources/assets/anvilcraft/textures/gui/container/warning_material.png and /dev/null differ diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/warning_none.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/warning_none.png deleted file mode 100644 index 5a5da3b3b..000000000 Binary files a/common/src/main/resources/assets/anvilcraft/textures/gui/container/warning_none.png and /dev/null differ diff --git a/common/src/main/resources/assets/anvilcraft/textures/gui/container/warning_protocol.png b/common/src/main/resources/assets/anvilcraft/textures/gui/container/warning_protocol.png deleted file mode 100644 index 486626d6a..000000000 Binary files a/common/src/main/resources/assets/anvilcraft/textures/gui/container/warning_protocol.png and /dev/null differ diff --git a/common/src/main/resources/assets/anvilcraft/textures/icon.png b/common/src/main/resources/pack.png similarity index 100% rename from common/src/main/resources/assets/anvilcraft/textures/icon.png rename to common/src/main/resources/pack.png 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 a7e4e43d3..175cc6276 100644 --- a/fabric/src/generated/resources/assets/anvilcraft/lang/en_ud.json +++ b/fabric/src/generated/resources/assets/anvilcraft/lang/en_ud.json @@ -3,11 +3,13 @@ "block.anvilcraft.auto_crafter": "ɹǝʇɟɐɹƆ oʇnⱯ", "block.anvilcraft.chute": "ǝʇnɥƆ", "block.anvilcraft.corrupted_beacon": "uoɔɐǝᗺ pǝʇdnɹɹoƆ", + "block.anvilcraft.creative_dynamo": "oɯɐuʎᗡ ǝʌıʇɐǝɹƆ", "block.anvilcraft.cursed_gold_block": "ʞɔoןᗺ pןo⅁ pǝsɹnƆ", "block.anvilcraft.cut_royal_steel_block": "ʞɔoןᗺ ןǝǝʇS ןɐʎoᴚ ʇnƆ", "block.anvilcraft.cut_royal_steel_slab": "qɐןS ןǝǝʇS ןɐʎoᴚ ʇnƆ", "block.anvilcraft.cut_royal_steel_stairs": "sɹıɐʇS ןǝǝʇS ןɐʎoᴚ ʇnƆ", "block.anvilcraft.ferrite_core_magnet_block": "ʞɔoןᗺ ʇǝubɐW ǝɹoƆ ǝʇıɹɹǝℲ", + "block.anvilcraft.heater": "ɹǝʇɐǝH", "block.anvilcraft.hollow_magnet_block": "ʞɔoןᗺ ʇǝubɐW ʍoןןoH", "block.anvilcraft.lava_cauldron": "uoɹpןnɐƆ ɐʌɐꞀ", "block.anvilcraft.magnet_block": "ʞɔoןᗺ ʇǝubɐW", @@ -22,6 +24,7 @@ "block.anvilcraft.smooth_royal_steel_block": "ʞɔoןᗺ ןǝǝʇS ןɐʎoᴚ ɥʇooɯS", "block.anvilcraft.stamping_platform": "ɯɹoɟʇɐןԀ buıdɯɐʇS", "block.anvilcraft.topaz_block": "ʞɔoןᗺ zɐdo⟘", + "block.anvilcraft.transmission_pole": "ǝןoԀ uoıssıɯsuɐɹ⟘", "item.anvilcraft.amber": "ɹǝqɯⱯ", "item.anvilcraft.amethyst_axe": "ǝxⱯ ʇsʎɥʇǝɯⱯ", "item.anvilcraft.amethyst_hoe": "ǝoH ʇsʎɥʇǝɯⱯ", @@ -33,6 +36,8 @@ "item.anvilcraft.bark": "ʞɹɐᗺ", "item.anvilcraft.beef_mushroom_stew": "ʍǝʇS ɯooɹɥsnW ɟǝǝᗺ", "item.anvilcraft.beef_mushroom_stew_raw": "ʍɐᴚ ʍǝʇS ɯooɹɥsnW ɟǝǝᗺ", + "item.anvilcraft.capacitor": "ɹoʇıɔɐdɐƆ", + "item.anvilcraft.capacitor_empty": "ʎʇdɯƎ ɹoʇıɔɐdɐƆ", "item.anvilcraft.chocolate": "ǝʇɐןoɔoɥƆ", "item.anvilcraft.chocolate_black": "ʞɔɐןᗺ ǝʇɐןoɔoɥƆ", "item.anvilcraft.chocolate_white": "ǝʇıɥM ǝʇɐןoɔoɥƆ", @@ -54,6 +59,7 @@ "item.anvilcraft.hardend_resin": "uısǝᴚ puǝpɹɐH", "item.anvilcraft.magnet": "ʇǝubɐW", "item.anvilcraft.magnet_ingot": "ʇobuI ʇǝubɐW", + "item.anvilcraft.magnetoelectric_core": "ǝɹoƆ ɔıɹʇɔǝןǝoʇǝubɐW", "item.anvilcraft.nether_star_shard": "pɹɐɥS ɹɐʇS ɹǝɥʇǝN", "item.anvilcraft.netherite_coil": "ןıoƆ ǝʇıɹǝɥʇǝN", "item.anvilcraft.netherite_core": "ǝɹoƆ ǝʇıɹǝɥʇǝN", @@ -64,6 +70,7 @@ "item.anvilcraft.royal_steel_ingot": "ʇobuI ןǝǝʇS ןɐʎoᴚ", "item.anvilcraft.royal_steel_nugget": "ʇǝbbnN ןǝǝʇS ןɐʎoᴚ", "item.anvilcraft.royal_steel_pickaxe": "ǝxɐʞɔıԀ ןǝǝʇS ןɐʎoᴚ", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "ǝʇɐןdɯǝ⟘ buıɥʇıɯS ǝpɐɹbd∩ ןǝǝʇS ןɐʎoᴚ", "item.anvilcraft.ruby": "ʎqnᴚ", "item.anvilcraft.sapphire": "ǝɹıɥddɐS", "item.anvilcraft.sea_heart_shell": "ןןǝɥS ʇɹɐǝH ɐǝS", @@ -73,7 +80,6 @@ "item.anvilcraft.utusan": "uɐsnʇ∩", "item.anvilcraft.utusan_raw": "ʍɐᴚ uɐsnʇ∩", "item.anvilcraft.wood_fiber": "ɹǝqıℲ pooM", - "item.minecraft.smithing_template": "ǝʇɐןdɯǝ⟘ buıɥʇıɯS ǝpɐɹbd∩ ןǝǝʇS ןɐʎoᴚ", "itemGroup.anvilcraft.block": "ʞɔoןᗺ", "itemGroup.anvilcraft.item": "ɯǝʇI", "screen.anvilcraft.button.direction": "%s :uoıʇɔǝɹıᗡ ʇndʇnO", @@ -114,6 +120,8 @@ "text.autoconfig.anvilcraft.option.magnetAttractsDistance.@Tooltip": "sʇɔɐɹʇʇɐ ʇǝubɐɯ ɐ ǝɔuɐʇsıp ɯnɯıxɐW", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius": "snıpɐᴚ sʇɔɐɹʇʇⱯ ɯǝʇI ʇǝubɐW", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius.@Tooltip": "sʇɔɐɹʇʇɐ ʇǝubɐɯ pןǝɥpuɐɥ ɐ snıpɐɹ ɯnɯıxɐW", + "text.autoconfig.anvilcraft.option.powerTransmitterRange": "ɹǝʇʇıɯsuɐɹ⟘ ɹǝʍoԀ ɟo ǝbuɐᴚ", + "text.autoconfig.anvilcraft.option.powerTransmitterRange.@Tooltip": "ɹǝʇʇıɯsuɐɹʇ ɹǝʍod ǝɥʇ ɟo ǝbuɐɹ ǝɥʇ ʎɟıʇuǝpı uɐɔ ɹǝʇʇıɯsuɐɹʇ ɹǝʍod ǝɥ⟘", "text.autoconfig.anvilcraft.option.redstoneEmpMaxRadius": "snıpɐᴚ xɐW dɯƎ ǝuoʇspǝᴚ", "text.autoconfig.anvilcraft.option.redstoneEmpMaxRadius.@Tooltip": "ԀWƎ ǝuoʇspǝɹ ɟo ǝɔuɐʇsıp ɯnɯıxɐW", "text.autoconfig.anvilcraft.option.redstoneEmpRadius": "ʞɔoןᗺ ɹǝԀ snıpɐᴚ ԀWƎ ǝuoʇspǝᴚ", 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 fb509a896..078b89b09 100644 --- a/fabric/src/generated/resources/assets/anvilcraft/lang/en_us.json +++ b/fabric/src/generated/resources/assets/anvilcraft/lang/en_us.json @@ -3,11 +3,13 @@ "block.anvilcraft.auto_crafter": "Auto Crafter", "block.anvilcraft.chute": "Chute", "block.anvilcraft.corrupted_beacon": "Corrupted Beacon", + "block.anvilcraft.creative_dynamo": "Creative Dynamo", "block.anvilcraft.cursed_gold_block": "Cursed Gold Block", "block.anvilcraft.cut_royal_steel_block": "Cut Royal Steel Block", "block.anvilcraft.cut_royal_steel_slab": "Cut Royal Steel Slab", "block.anvilcraft.cut_royal_steel_stairs": "Cut Royal Steel Stairs", "block.anvilcraft.ferrite_core_magnet_block": "Ferrite Core Magnet Block", + "block.anvilcraft.heater": "Heater", "block.anvilcraft.hollow_magnet_block": "Hollow Magnet Block", "block.anvilcraft.lava_cauldron": "Lava Cauldron", "block.anvilcraft.magnet_block": "Magnet Block", @@ -22,6 +24,7 @@ "block.anvilcraft.smooth_royal_steel_block": "Smooth Royal Steel Block", "block.anvilcraft.stamping_platform": "Stamping Platform", "block.anvilcraft.topaz_block": "Topaz Block", + "block.anvilcraft.transmission_pole": "Transmission Pole", "item.anvilcraft.amber": "Amber", "item.anvilcraft.amethyst_axe": "Amethyst Axe", "item.anvilcraft.amethyst_hoe": "Amethyst Hoe", @@ -33,6 +36,8 @@ "item.anvilcraft.bark": "Bark", "item.anvilcraft.beef_mushroom_stew": "Beef Mushroom Stew", "item.anvilcraft.beef_mushroom_stew_raw": "Beef Mushroom Stew Raw", + "item.anvilcraft.capacitor": "Capacitor", + "item.anvilcraft.capacitor_empty": "Capacitor Empty", "item.anvilcraft.chocolate": "Chocolate", "item.anvilcraft.chocolate_black": "Chocolate Black", "item.anvilcraft.chocolate_white": "Chocolate White", @@ -54,6 +59,7 @@ "item.anvilcraft.hardend_resin": "Hardend Resin", "item.anvilcraft.magnet": "Magnet", "item.anvilcraft.magnet_ingot": "Magnet Ingot", + "item.anvilcraft.magnetoelectric_core": "Magnetoelectric Core", "item.anvilcraft.nether_star_shard": "Nether Star Shard", "item.anvilcraft.netherite_coil": "Netherite Coil", "item.anvilcraft.netherite_core": "Netherite Core", @@ -64,6 +70,7 @@ "item.anvilcraft.royal_steel_ingot": "Royal Steel Ingot", "item.anvilcraft.royal_steel_nugget": "Royal Steel Nugget", "item.anvilcraft.royal_steel_pickaxe": "Royal Steel Pickaxe", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "Royal Steel Upgrade Smithing Template", "item.anvilcraft.ruby": "Ruby", "item.anvilcraft.sapphire": "Sapphire", "item.anvilcraft.sea_heart_shell": "Sea Heart Shell", @@ -73,7 +80,6 @@ "item.anvilcraft.utusan": "Utusan", "item.anvilcraft.utusan_raw": "Utusan Raw", "item.anvilcraft.wood_fiber": "Wood Fiber", - "item.minecraft.smithing_template": "Royal Steel Upgrade Smithing Template", "itemGroup.anvilcraft.block": "Block", "itemGroup.anvilcraft.item": "Item", "screen.anvilcraft.button.direction": "Output Direction: %s", @@ -114,6 +120,8 @@ "text.autoconfig.anvilcraft.option.magnetAttractsDistance.@Tooltip": "Maximum distance a magnet attracts", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius": "Magnet Item Attracts Radius", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius.@Tooltip": "Maximum radius a handheld magnet attracts", + "text.autoconfig.anvilcraft.option.powerTransmitterRange": "Range of Power Transmitter", + "text.autoconfig.anvilcraft.option.powerTransmitterRange.@Tooltip": "The power transmitter can identify the range of the power transmitter", "text.autoconfig.anvilcraft.option.redstoneEmpMaxRadius": "Redstone Emp Max Radius", "text.autoconfig.anvilcraft.option.redstoneEmpMaxRadius.@Tooltip": "Maximum distance of redstone EMP", "text.autoconfig.anvilcraft.option.redstoneEmpRadius": "Redstone EMP Radius Per Block", diff --git a/fabric/src/generated/resources/assets/anvilcraft/models/item/capacitor.json b/fabric/src/generated/resources/assets/anvilcraft/models/item/capacitor.json new file mode 100644 index 000000000..2c835c265 --- /dev/null +++ b/fabric/src/generated/resources/assets/anvilcraft/models/item/capacitor.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "anvilcraft:item/capacitor" + } +} \ No newline at end of file diff --git a/fabric/src/generated/resources/assets/anvilcraft/models/item/capacitor_empty.json b/fabric/src/generated/resources/assets/anvilcraft/models/item/capacitor_empty.json new file mode 100644 index 000000000..918a2326f --- /dev/null +++ b/fabric/src/generated/resources/assets/anvilcraft/models/item/capacitor_empty.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "anvilcraft:item/capacitor_empty" + } +} \ No newline at end of file diff --git a/fabric/src/generated/resources/assets/anvilcraft/models/item/creative_dynamo.json b/fabric/src/generated/resources/assets/anvilcraft/models/item/creative_dynamo.json new file mode 100644 index 000000000..14133ea10 --- /dev/null +++ b/fabric/src/generated/resources/assets/anvilcraft/models/item/creative_dynamo.json @@ -0,0 +1,3 @@ +{ + "parent": "anvilcraft:block/creative_dynamo" +} \ No newline at end of file diff --git a/fabric/src/generated/resources/assets/anvilcraft/models/item/heater.json b/fabric/src/generated/resources/assets/anvilcraft/models/item/heater.json new file mode 100644 index 000000000..cd6191eee --- /dev/null +++ b/fabric/src/generated/resources/assets/anvilcraft/models/item/heater.json @@ -0,0 +1,3 @@ +{ + "parent": "anvilcraft:block/heater" +} \ No newline at end of file diff --git a/fabric/src/generated/resources/assets/anvilcraft/models/item/magnetoelectric_core.json b/fabric/src/generated/resources/assets/anvilcraft/models/item/magnetoelectric_core.json new file mode 100644 index 000000000..d737a7181 --- /dev/null +++ b/fabric/src/generated/resources/assets/anvilcraft/models/item/magnetoelectric_core.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "anvilcraft:item/magnetoelectric_core" + } +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/misc/heater.json b/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/misc/heater.json new file mode 100644 index 000000000..2e92dd13e --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/misc/heater.json @@ -0,0 +1,59 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_capacitor": { + "conditions": { + "items": [ + { + "tag": "anvilcraft:capacitor" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_iron_ingot": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:iron_ingot" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_terracotta": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:terracotta" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "anvilcraft:heater" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_terracotta", + "has_iron_ingot", + "has_capacitor", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "anvilcraft:heater" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/misc/transmission_pole.json b/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/misc/transmission_pole.json new file mode 100644 index 000000000..abe92012d --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/misc/transmission_pole.json @@ -0,0 +1,61 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_iron_block": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:iron_block" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_lightning_rod": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:lightning_rod" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_magnetoelectric_core": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:magnetoelectric_core" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "anvilcraft:transmission_pole" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_magnetoelectric_core", + "has_lightning_rod", + "has_iron_block", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "anvilcraft:transmission_pole" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/tools/capacitor_empty.json b/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/tools/capacitor_empty.json new file mode 100644 index 000000000..c744d1652 --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/advancements/recipes/tools/capacitor_empty.json @@ -0,0 +1,61 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_copper_ingot": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:copper_ingot" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_iron_ingot": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:iron_ingot" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_terracotta": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:terracotta" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "anvilcraft:capacitor_empty" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_iron_ingot", + "has_copper_ingot", + "has_terracotta", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "anvilcraft:capacitor_empty" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/creative_dynamo.json b/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/creative_dynamo.json new file mode 100644 index 000000000..e42b9a45b --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/creative_dynamo.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "anvilcraft:creative_dynamo" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "anvilcraft:blocks/creative_dynamo" +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/heater.json b/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/heater.json new file mode 100644 index 000000000..b52eb06c6 --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/heater.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "anvilcraft:heater" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "anvilcraft:blocks/heater" +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/transmission_pole.json b/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/transmission_pole.json new file mode 100644 index 000000000..a9851c7d3 --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/loot_tables/blocks/transmission_pole.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "anvilcraft:transmission_pole" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "anvilcraft:blocks/transmission_pole" +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/recipes/capacitor_empty.json b/fabric/src/generated/resources/data/anvilcraft/recipes/capacitor_empty.json new file mode 100644 index 000000000..5b80905be --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/recipes/capacitor_empty.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "A": { + "item": "minecraft:iron_ingot" + }, + "B": { + "item": "minecraft:copper_ingot" + }, + "C": { + "item": "minecraft:terracotta" + } + }, + "pattern": [ + "ABA", + "ACA", + "ABA" + ], + "result": { + "item": "anvilcraft:capacitor_empty" + }, + "show_notification": true +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/recipes/heater.json b/fabric/src/generated/resources/data/anvilcraft/recipes/heater.json new file mode 100644 index 000000000..9ae50f2d4 --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/recipes/heater.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "item": "minecraft:terracotta" + }, + "B": { + "item": "minecraft:iron_ingot" + }, + "C": { + "tag": "anvilcraft:capacitor" + } + }, + "pattern": [ + "ABA", + "BCB", + "BBB" + ], + "result": { + "item": "anvilcraft:heater" + }, + "show_notification": true +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/recipes/transmission_pole.json b/fabric/src/generated/resources/data/anvilcraft/recipes/transmission_pole.json new file mode 100644 index 000000000..f61b8caee --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/recipes/transmission_pole.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "item": "anvilcraft:magnetoelectric_core" + }, + "B": { + "item": "minecraft:lightning_rod" + }, + "C": { + "item": "minecraft:iron_block" + } + }, + "pattern": [ + "A", + "B", + "C" + ], + "result": { + "item": "anvilcraft:transmission_pole" + }, + "show_notification": true +} \ No newline at end of file diff --git a/fabric/src/generated/resources/data/anvilcraft/tags/items/capacitor.json b/fabric/src/generated/resources/data/anvilcraft/tags/items/capacitor.json new file mode 100644 index 000000000..20bbc5532 --- /dev/null +++ b/fabric/src/generated/resources/data/anvilcraft/tags/items/capacitor.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "anvilcraft:capacitor", + "anvilcraft:capacitor_empty" + ] +} \ 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 4eb682c20..ad0c2f909 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 @@ -23,6 +23,9 @@ "anvilcraft:ruby_block", "anvilcraft:sapphire_block", "anvilcraft:resin_block", - "anvilcraft:amber_block" + "anvilcraft:amber_block", + "anvilcraft:creative_dynamo", + "anvilcraft:heater", + "anvilcraft:transmission_pole" ] } \ No newline at end of file diff --git a/fabric/src/main/java/dev/dubhe/anvilcraft/client/fabric/AnvilCraftClient.java b/fabric/src/main/java/dev/dubhe/anvilcraft/client/fabric/AnvilCraftFabricClient.java similarity index 87% rename from fabric/src/main/java/dev/dubhe/anvilcraft/client/fabric/AnvilCraftClient.java rename to fabric/src/main/java/dev/dubhe/anvilcraft/client/fabric/AnvilCraftFabricClient.java index cf1efa361..a729fd22b 100644 --- a/fabric/src/main/java/dev/dubhe/anvilcraft/client/fabric/AnvilCraftClient.java +++ b/fabric/src/main/java/dev/dubhe/anvilcraft/client/fabric/AnvilCraftFabricClient.java @@ -8,12 +8,13 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; -public class AnvilCraftClient implements ClientModInitializer { +public class AnvilCraftFabricClient implements ClientModInitializer { @Override public void onInitializeClient() { BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.CORRUPTED_BEACON.get(), RenderType.translucent()); BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.RESIN_BLOCK.get(), RenderType.translucent()); BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.AMBER_BLOCK.get(), RenderType.translucent()); + BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.HEATER.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/ModFabricEvents.java b/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ModFabricEvents.java index 405ff50f2..8d5207f5e 100644 --- a/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ModFabricEvents.java +++ b/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ModFabricEvents.java @@ -10,6 +10,7 @@ public static void init() { LootTableEvent.init(); LightningEvent.init(); AnvilEntityEvent.init(); + ServerBlockEntityEvent.init(); CommandEvent.init(); } } diff --git a/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerBlockEntityEvent.java b/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerBlockEntityEvent.java new file mode 100644 index 000000000..ac5c6d7f2 --- /dev/null +++ b/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerBlockEntityEvent.java @@ -0,0 +1,26 @@ +package dev.dubhe.anvilcraft.event.fabric; + +import dev.dubhe.anvilcraft.api.power.IPowerComponent; +import dev.dubhe.anvilcraft.api.power.PowerGrid; +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerBlockEntityEvents; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.entity.BlockEntity; + +public class ServerBlockEntityEvent { + public static void init() { + ServerBlockEntityEvents.BLOCK_ENTITY_LOAD.register(ServerBlockEntityEvent::onLoad); + ServerBlockEntityEvents.BLOCK_ENTITY_UNLOAD.register(ServerBlockEntityEvent::onUnload); + } + + private static void onLoad(BlockEntity entity, ServerLevel level) { + if (entity instanceof IPowerComponent component) { + PowerGrid.addComponent(component); + } + } + + private static void onUnload(BlockEntity entity, ServerLevel level) { + if (entity instanceof IPowerComponent component) { + PowerGrid.removeComponent(component); + } + } +} diff --git a/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerLifecycleEvent.java b/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerLifecycleEvent.java index c605e78c2..3804dff1e 100644 --- a/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerLifecycleEvent.java +++ b/fabric/src/main/java/dev/dubhe/anvilcraft/event/fabric/ServerLifecycleEvent.java @@ -3,8 +3,10 @@ import dev.dubhe.anvilcraft.AnvilCraft; import dev.dubhe.anvilcraft.api.event.server.ServerEndDataPackReloadEvent; import dev.dubhe.anvilcraft.api.event.server.ServerStartedEvent; +import dev.dubhe.anvilcraft.api.power.PowerGrid; import dev.dubhe.anvilcraft.utils.fabric.ServerHooks; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.minecraft.server.MinecraftServer; import net.minecraft.server.packs.resources.CloseableResourceManager; @@ -15,16 +17,32 @@ public class ServerLifecycleEvent { public static void init() { ServerLifecycleEvents.SERVER_STARTED.register(ServerLifecycleEvent::serverStarted); ServerLifecycleEvents.END_DATA_PACK_RELOAD.register(ServerLifecycleEvent::endDataPackReload); + ServerLifecycleEvents.SERVER_STOPPING.register(ServerLifecycleEvent::onServerStopping); + ServerLifecycleEvents.SERVER_STOPPED.register(ServerLifecycleEvent::onServerStopped); + ServerTickEvents.START_SERVER_TICK.register(ServerLifecycleEvent::startTick); } - public static void serverStarted(MinecraftServer server) { + private static void serverStarted(MinecraftServer server) { ServerHooks.setServer(server); AnvilCraft.EVENT_BUS.post(new ServerStartedEvent(server)); } - public static void endDataPackReload( + private static void endDataPackReload( MinecraftServer server, CloseableResourceManager resourceManager, boolean success ) { AnvilCraft.EVENT_BUS.post(new ServerEndDataPackReloadEvent(server, resourceManager)); } + + private static void startTick(MinecraftServer server) { + PowerGrid.tickGrid(); + } + + private static void onServerStopping(MinecraftServer server) { + PowerGrid.isServerClosing = true; + } + + private static void onServerStopped(MinecraftServer server) { + PowerGrid.isServerClosing = false; + PowerGrid.clear(); + } } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 32be2b56a..e3c86e4d9 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -15,12 +15,12 @@ }, "license": "${mod_license}", - "icon": "assets/anvilcraft/textures/icon.png", + "icon": "pack.png", "environment": "*", "entrypoints": { "client": [ - "dev.dubhe.anvilcraft.client.fabric.AnvilCraftClient" + "dev.dubhe.anvilcraft.client.fabric.AnvilCraftFabricClient" ], "main": [ "dev.dubhe.anvilcraft.fabric.AnvilCraftFabric" 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 a7e4e43d3..175cc6276 100644 --- a/forge/src/generated/resources/assets/anvilcraft/lang/en_ud.json +++ b/forge/src/generated/resources/assets/anvilcraft/lang/en_ud.json @@ -3,11 +3,13 @@ "block.anvilcraft.auto_crafter": "ɹǝʇɟɐɹƆ oʇnⱯ", "block.anvilcraft.chute": "ǝʇnɥƆ", "block.anvilcraft.corrupted_beacon": "uoɔɐǝᗺ pǝʇdnɹɹoƆ", + "block.anvilcraft.creative_dynamo": "oɯɐuʎᗡ ǝʌıʇɐǝɹƆ", "block.anvilcraft.cursed_gold_block": "ʞɔoןᗺ pןo⅁ pǝsɹnƆ", "block.anvilcraft.cut_royal_steel_block": "ʞɔoןᗺ ןǝǝʇS ןɐʎoᴚ ʇnƆ", "block.anvilcraft.cut_royal_steel_slab": "qɐןS ןǝǝʇS ןɐʎoᴚ ʇnƆ", "block.anvilcraft.cut_royal_steel_stairs": "sɹıɐʇS ןǝǝʇS ןɐʎoᴚ ʇnƆ", "block.anvilcraft.ferrite_core_magnet_block": "ʞɔoןᗺ ʇǝubɐW ǝɹoƆ ǝʇıɹɹǝℲ", + "block.anvilcraft.heater": "ɹǝʇɐǝH", "block.anvilcraft.hollow_magnet_block": "ʞɔoןᗺ ʇǝubɐW ʍoןןoH", "block.anvilcraft.lava_cauldron": "uoɹpןnɐƆ ɐʌɐꞀ", "block.anvilcraft.magnet_block": "ʞɔoןᗺ ʇǝubɐW", @@ -22,6 +24,7 @@ "block.anvilcraft.smooth_royal_steel_block": "ʞɔoןᗺ ןǝǝʇS ןɐʎoᴚ ɥʇooɯS", "block.anvilcraft.stamping_platform": "ɯɹoɟʇɐןԀ buıdɯɐʇS", "block.anvilcraft.topaz_block": "ʞɔoןᗺ zɐdo⟘", + "block.anvilcraft.transmission_pole": "ǝןoԀ uoıssıɯsuɐɹ⟘", "item.anvilcraft.amber": "ɹǝqɯⱯ", "item.anvilcraft.amethyst_axe": "ǝxⱯ ʇsʎɥʇǝɯⱯ", "item.anvilcraft.amethyst_hoe": "ǝoH ʇsʎɥʇǝɯⱯ", @@ -33,6 +36,8 @@ "item.anvilcraft.bark": "ʞɹɐᗺ", "item.anvilcraft.beef_mushroom_stew": "ʍǝʇS ɯooɹɥsnW ɟǝǝᗺ", "item.anvilcraft.beef_mushroom_stew_raw": "ʍɐᴚ ʍǝʇS ɯooɹɥsnW ɟǝǝᗺ", + "item.anvilcraft.capacitor": "ɹoʇıɔɐdɐƆ", + "item.anvilcraft.capacitor_empty": "ʎʇdɯƎ ɹoʇıɔɐdɐƆ", "item.anvilcraft.chocolate": "ǝʇɐןoɔoɥƆ", "item.anvilcraft.chocolate_black": "ʞɔɐןᗺ ǝʇɐןoɔoɥƆ", "item.anvilcraft.chocolate_white": "ǝʇıɥM ǝʇɐןoɔoɥƆ", @@ -54,6 +59,7 @@ "item.anvilcraft.hardend_resin": "uısǝᴚ puǝpɹɐH", "item.anvilcraft.magnet": "ʇǝubɐW", "item.anvilcraft.magnet_ingot": "ʇobuI ʇǝubɐW", + "item.anvilcraft.magnetoelectric_core": "ǝɹoƆ ɔıɹʇɔǝןǝoʇǝubɐW", "item.anvilcraft.nether_star_shard": "pɹɐɥS ɹɐʇS ɹǝɥʇǝN", "item.anvilcraft.netherite_coil": "ןıoƆ ǝʇıɹǝɥʇǝN", "item.anvilcraft.netherite_core": "ǝɹoƆ ǝʇıɹǝɥʇǝN", @@ -64,6 +70,7 @@ "item.anvilcraft.royal_steel_ingot": "ʇobuI ןǝǝʇS ןɐʎoᴚ", "item.anvilcraft.royal_steel_nugget": "ʇǝbbnN ןǝǝʇS ןɐʎoᴚ", "item.anvilcraft.royal_steel_pickaxe": "ǝxɐʞɔıԀ ןǝǝʇS ןɐʎoᴚ", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "ǝʇɐןdɯǝ⟘ buıɥʇıɯS ǝpɐɹbd∩ ןǝǝʇS ןɐʎoᴚ", "item.anvilcraft.ruby": "ʎqnᴚ", "item.anvilcraft.sapphire": "ǝɹıɥddɐS", "item.anvilcraft.sea_heart_shell": "ןןǝɥS ʇɹɐǝH ɐǝS", @@ -73,7 +80,6 @@ "item.anvilcraft.utusan": "uɐsnʇ∩", "item.anvilcraft.utusan_raw": "ʍɐᴚ uɐsnʇ∩", "item.anvilcraft.wood_fiber": "ɹǝqıℲ pooM", - "item.minecraft.smithing_template": "ǝʇɐןdɯǝ⟘ buıɥʇıɯS ǝpɐɹbd∩ ןǝǝʇS ןɐʎoᴚ", "itemGroup.anvilcraft.block": "ʞɔoןᗺ", "itemGroup.anvilcraft.item": "ɯǝʇI", "screen.anvilcraft.button.direction": "%s :uoıʇɔǝɹıᗡ ʇndʇnO", @@ -114,6 +120,8 @@ "text.autoconfig.anvilcraft.option.magnetAttractsDistance.@Tooltip": "sʇɔɐɹʇʇɐ ʇǝubɐɯ ɐ ǝɔuɐʇsıp ɯnɯıxɐW", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius": "snıpɐᴚ sʇɔɐɹʇʇⱯ ɯǝʇI ʇǝubɐW", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius.@Tooltip": "sʇɔɐɹʇʇɐ ʇǝubɐɯ pןǝɥpuɐɥ ɐ snıpɐɹ ɯnɯıxɐW", + "text.autoconfig.anvilcraft.option.powerTransmitterRange": "ɹǝʇʇıɯsuɐɹ⟘ ɹǝʍoԀ ɟo ǝbuɐᴚ", + "text.autoconfig.anvilcraft.option.powerTransmitterRange.@Tooltip": "ɹǝʇʇıɯsuɐɹʇ ɹǝʍod ǝɥʇ ɟo ǝbuɐɹ ǝɥʇ ʎɟıʇuǝpı uɐɔ ɹǝʇʇıɯsuɐɹʇ ɹǝʍod ǝɥ⟘", "text.autoconfig.anvilcraft.option.redstoneEmpMaxRadius": "snıpɐᴚ xɐW dɯƎ ǝuoʇspǝᴚ", "text.autoconfig.anvilcraft.option.redstoneEmpMaxRadius.@Tooltip": "ԀWƎ ǝuoʇspǝɹ ɟo ǝɔuɐʇsıp ɯnɯıxɐW", "text.autoconfig.anvilcraft.option.redstoneEmpRadius": "ʞɔoןᗺ ɹǝԀ snıpɐᴚ ԀWƎ ǝuoʇspǝᴚ", 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 fb509a896..078b89b09 100644 --- a/forge/src/generated/resources/assets/anvilcraft/lang/en_us.json +++ b/forge/src/generated/resources/assets/anvilcraft/lang/en_us.json @@ -3,11 +3,13 @@ "block.anvilcraft.auto_crafter": "Auto Crafter", "block.anvilcraft.chute": "Chute", "block.anvilcraft.corrupted_beacon": "Corrupted Beacon", + "block.anvilcraft.creative_dynamo": "Creative Dynamo", "block.anvilcraft.cursed_gold_block": "Cursed Gold Block", "block.anvilcraft.cut_royal_steel_block": "Cut Royal Steel Block", "block.anvilcraft.cut_royal_steel_slab": "Cut Royal Steel Slab", "block.anvilcraft.cut_royal_steel_stairs": "Cut Royal Steel Stairs", "block.anvilcraft.ferrite_core_magnet_block": "Ferrite Core Magnet Block", + "block.anvilcraft.heater": "Heater", "block.anvilcraft.hollow_magnet_block": "Hollow Magnet Block", "block.anvilcraft.lava_cauldron": "Lava Cauldron", "block.anvilcraft.magnet_block": "Magnet Block", @@ -22,6 +24,7 @@ "block.anvilcraft.smooth_royal_steel_block": "Smooth Royal Steel Block", "block.anvilcraft.stamping_platform": "Stamping Platform", "block.anvilcraft.topaz_block": "Topaz Block", + "block.anvilcraft.transmission_pole": "Transmission Pole", "item.anvilcraft.amber": "Amber", "item.anvilcraft.amethyst_axe": "Amethyst Axe", "item.anvilcraft.amethyst_hoe": "Amethyst Hoe", @@ -33,6 +36,8 @@ "item.anvilcraft.bark": "Bark", "item.anvilcraft.beef_mushroom_stew": "Beef Mushroom Stew", "item.anvilcraft.beef_mushroom_stew_raw": "Beef Mushroom Stew Raw", + "item.anvilcraft.capacitor": "Capacitor", + "item.anvilcraft.capacitor_empty": "Capacitor Empty", "item.anvilcraft.chocolate": "Chocolate", "item.anvilcraft.chocolate_black": "Chocolate Black", "item.anvilcraft.chocolate_white": "Chocolate White", @@ -54,6 +59,7 @@ "item.anvilcraft.hardend_resin": "Hardend Resin", "item.anvilcraft.magnet": "Magnet", "item.anvilcraft.magnet_ingot": "Magnet Ingot", + "item.anvilcraft.magnetoelectric_core": "Magnetoelectric Core", "item.anvilcraft.nether_star_shard": "Nether Star Shard", "item.anvilcraft.netherite_coil": "Netherite Coil", "item.anvilcraft.netherite_core": "Netherite Core", @@ -64,6 +70,7 @@ "item.anvilcraft.royal_steel_ingot": "Royal Steel Ingot", "item.anvilcraft.royal_steel_nugget": "Royal Steel Nugget", "item.anvilcraft.royal_steel_pickaxe": "Royal Steel Pickaxe", + "item.anvilcraft.royal_steel_upgrade_smithing_template": "Royal Steel Upgrade Smithing Template", "item.anvilcraft.ruby": "Ruby", "item.anvilcraft.sapphire": "Sapphire", "item.anvilcraft.sea_heart_shell": "Sea Heart Shell", @@ -73,7 +80,6 @@ "item.anvilcraft.utusan": "Utusan", "item.anvilcraft.utusan_raw": "Utusan Raw", "item.anvilcraft.wood_fiber": "Wood Fiber", - "item.minecraft.smithing_template": "Royal Steel Upgrade Smithing Template", "itemGroup.anvilcraft.block": "Block", "itemGroup.anvilcraft.item": "Item", "screen.anvilcraft.button.direction": "Output Direction: %s", @@ -114,6 +120,8 @@ "text.autoconfig.anvilcraft.option.magnetAttractsDistance.@Tooltip": "Maximum distance a magnet attracts", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius": "Magnet Item Attracts Radius", "text.autoconfig.anvilcraft.option.magnetItemAttractsRadius.@Tooltip": "Maximum radius a handheld magnet attracts", + "text.autoconfig.anvilcraft.option.powerTransmitterRange": "Range of Power Transmitter", + "text.autoconfig.anvilcraft.option.powerTransmitterRange.@Tooltip": "The power transmitter can identify the range of the power transmitter", "text.autoconfig.anvilcraft.option.redstoneEmpMaxRadius": "Redstone Emp Max Radius", "text.autoconfig.anvilcraft.option.redstoneEmpMaxRadius.@Tooltip": "Maximum distance of redstone EMP", "text.autoconfig.anvilcraft.option.redstoneEmpRadius": "Redstone EMP Radius Per Block", diff --git a/forge/src/generated/resources/assets/anvilcraft/models/item/capacitor.json b/forge/src/generated/resources/assets/anvilcraft/models/item/capacitor.json new file mode 100644 index 000000000..2c835c265 --- /dev/null +++ b/forge/src/generated/resources/assets/anvilcraft/models/item/capacitor.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "anvilcraft:item/capacitor" + } +} \ No newline at end of file diff --git a/forge/src/generated/resources/assets/anvilcraft/models/item/capacitor_empty.json b/forge/src/generated/resources/assets/anvilcraft/models/item/capacitor_empty.json new file mode 100644 index 000000000..918a2326f --- /dev/null +++ b/forge/src/generated/resources/assets/anvilcraft/models/item/capacitor_empty.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "anvilcraft:item/capacitor_empty" + } +} \ No newline at end of file diff --git a/forge/src/generated/resources/assets/anvilcraft/models/item/creative_dynamo.json b/forge/src/generated/resources/assets/anvilcraft/models/item/creative_dynamo.json new file mode 100644 index 000000000..14133ea10 --- /dev/null +++ b/forge/src/generated/resources/assets/anvilcraft/models/item/creative_dynamo.json @@ -0,0 +1,3 @@ +{ + "parent": "anvilcraft:block/creative_dynamo" +} \ No newline at end of file diff --git a/forge/src/generated/resources/assets/anvilcraft/models/item/heater.json b/forge/src/generated/resources/assets/anvilcraft/models/item/heater.json new file mode 100644 index 000000000..cd6191eee --- /dev/null +++ b/forge/src/generated/resources/assets/anvilcraft/models/item/heater.json @@ -0,0 +1,3 @@ +{ + "parent": "anvilcraft:block/heater" +} \ No newline at end of file diff --git a/forge/src/generated/resources/assets/anvilcraft/models/item/magnetoelectric_core.json b/forge/src/generated/resources/assets/anvilcraft/models/item/magnetoelectric_core.json new file mode 100644 index 000000000..d737a7181 --- /dev/null +++ b/forge/src/generated/resources/assets/anvilcraft/models/item/magnetoelectric_core.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "anvilcraft:item/magnetoelectric_core" + } +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/advancements/recipes/misc/heater.json b/forge/src/generated/resources/data/anvilcraft/advancements/recipes/misc/heater.json new file mode 100644 index 000000000..2e92dd13e --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/advancements/recipes/misc/heater.json @@ -0,0 +1,59 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_capacitor": { + "conditions": { + "items": [ + { + "tag": "anvilcraft:capacitor" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_iron_ingot": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:iron_ingot" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_terracotta": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:terracotta" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "anvilcraft:heater" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_terracotta", + "has_iron_ingot", + "has_capacitor", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "anvilcraft:heater" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/advancements/recipes/misc/transmission_pole.json b/forge/src/generated/resources/data/anvilcraft/advancements/recipes/misc/transmission_pole.json new file mode 100644 index 000000000..abe92012d --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/advancements/recipes/misc/transmission_pole.json @@ -0,0 +1,61 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_iron_block": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:iron_block" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_lightning_rod": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:lightning_rod" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_magnetoelectric_core": { + "conditions": { + "items": [ + { + "items": [ + "anvilcraft:magnetoelectric_core" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "anvilcraft:transmission_pole" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_magnetoelectric_core", + "has_lightning_rod", + "has_iron_block", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "anvilcraft:transmission_pole" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/advancements/recipes/tools/capacitor_empty.json b/forge/src/generated/resources/data/anvilcraft/advancements/recipes/tools/capacitor_empty.json new file mode 100644 index 000000000..c744d1652 --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/advancements/recipes/tools/capacitor_empty.json @@ -0,0 +1,61 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_copper_ingot": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:copper_ingot" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_iron_ingot": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:iron_ingot" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_terracotta": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:terracotta" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "anvilcraft:capacitor_empty" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_iron_ingot", + "has_copper_ingot", + "has_terracotta", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "anvilcraft:capacitor_empty" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/creative_dynamo.json b/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/creative_dynamo.json new file mode 100644 index 000000000..e42b9a45b --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/creative_dynamo.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "anvilcraft:creative_dynamo" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "anvilcraft:blocks/creative_dynamo" +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/heater.json b/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/heater.json new file mode 100644 index 000000000..b52eb06c6 --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/heater.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "anvilcraft:heater" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "anvilcraft:blocks/heater" +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/transmission_pole.json b/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/transmission_pole.json new file mode 100644 index 000000000..a9851c7d3 --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/loot_tables/blocks/transmission_pole.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "anvilcraft:transmission_pole" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "anvilcraft:blocks/transmission_pole" +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/recipes/capacitor_empty.json b/forge/src/generated/resources/data/anvilcraft/recipes/capacitor_empty.json new file mode 100644 index 000000000..5b80905be --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/recipes/capacitor_empty.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "A": { + "item": "minecraft:iron_ingot" + }, + "B": { + "item": "minecraft:copper_ingot" + }, + "C": { + "item": "minecraft:terracotta" + } + }, + "pattern": [ + "ABA", + "ACA", + "ABA" + ], + "result": { + "item": "anvilcraft:capacitor_empty" + }, + "show_notification": true +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/recipes/heater.json b/forge/src/generated/resources/data/anvilcraft/recipes/heater.json new file mode 100644 index 000000000..9ae50f2d4 --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/recipes/heater.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "item": "minecraft:terracotta" + }, + "B": { + "item": "minecraft:iron_ingot" + }, + "C": { + "tag": "anvilcraft:capacitor" + } + }, + "pattern": [ + "ABA", + "BCB", + "BBB" + ], + "result": { + "item": "anvilcraft:heater" + }, + "show_notification": true +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/recipes/transmission_pole.json b/forge/src/generated/resources/data/anvilcraft/recipes/transmission_pole.json new file mode 100644 index 000000000..f61b8caee --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/recipes/transmission_pole.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "item": "anvilcraft:magnetoelectric_core" + }, + "B": { + "item": "minecraft:lightning_rod" + }, + "C": { + "item": "minecraft:iron_block" + } + }, + "pattern": [ + "A", + "B", + "C" + ], + "result": { + "item": "anvilcraft:transmission_pole" + }, + "show_notification": true +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/anvilcraft/tags/items/capacitor.json b/forge/src/generated/resources/data/anvilcraft/tags/items/capacitor.json new file mode 100644 index 000000000..20bbc5532 --- /dev/null +++ b/forge/src/generated/resources/data/anvilcraft/tags/items/capacitor.json @@ -0,0 +1,7 @@ +{ + "replace": false, + "values": [ + "anvilcraft:capacitor", + "anvilcraft:capacitor_empty" + ] +} \ 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 4eb682c20..ad0c2f909 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 @@ -23,6 +23,9 @@ "anvilcraft:ruby_block", "anvilcraft:sapphire_block", "anvilcraft:resin_block", - "anvilcraft:amber_block" + "anvilcraft:amber_block", + "anvilcraft:creative_dynamo", + "anvilcraft:heater", + "anvilcraft:transmission_pole" ] } \ No newline at end of file diff --git a/forge/src/main/java/dev/dubhe/anvilcraft/api/event/forge/BlockEntityEvent.java b/forge/src/main/java/dev/dubhe/anvilcraft/api/event/forge/BlockEntityEvent.java new file mode 100644 index 000000000..9d8805703 --- /dev/null +++ b/forge/src/main/java/dev/dubhe/anvilcraft/api/event/forge/BlockEntityEvent.java @@ -0,0 +1,29 @@ +package dev.dubhe.anvilcraft.api.event.forge; + +import lombok.Getter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraftforge.eventbus.api.Event; + +@Getter +public class BlockEntityEvent extends Event { + private final Level level; + private final BlockEntity entity; + + public BlockEntityEvent(Level level, BlockEntity entity) { + this.level = level; + this.entity = entity; + } + + public static class ServerLoad extends BlockEntityEvent { + public ServerLoad(Level level, BlockEntity entity) { + super(level, entity); + } + } + + public static class ServerUnload extends BlockEntityEvent { + public ServerUnload(Level level, BlockEntity entity) { + super(level, entity); + } + } +} diff --git a/forge/src/main/java/dev/dubhe/anvilcraft/event/forge/ServerBlockEntityEvent.java b/forge/src/main/java/dev/dubhe/anvilcraft/event/forge/ServerBlockEntityEvent.java new file mode 100644 index 000000000..164c0e1e1 --- /dev/null +++ b/forge/src/main/java/dev/dubhe/anvilcraft/event/forge/ServerBlockEntityEvent.java @@ -0,0 +1,32 @@ +package dev.dubhe.anvilcraft.event.forge; + +import dev.dubhe.anvilcraft.AnvilCraft; +import dev.dubhe.anvilcraft.api.event.forge.BlockEntityEvent; +import dev.dubhe.anvilcraft.api.power.IPowerComponent; +import dev.dubhe.anvilcraft.api.power.PowerGrid; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import org.jetbrains.annotations.NotNull; + +@Mod.EventBusSubscriber(modid = AnvilCraft.MOD_ID) +public class ServerBlockEntityEvent { + /** + * @param event 服务端方块实体加载事件 + */ + @SubscribeEvent + public static void onLoad(@NotNull BlockEntityEvent.ServerLoad event) { + if (event.getEntity() instanceof IPowerComponent component) { + PowerGrid.addComponent(component); + } + } + + /** + * @param event 服务端方块实体卸载事件 + */ + @SubscribeEvent + public static void onUnload(@NotNull BlockEntityEvent.ServerUnload event) { + if (event.getEntity() instanceof IPowerComponent component) { + PowerGrid.removeComponent(component); + } + } +} diff --git a/forge/src/main/java/dev/dubhe/anvilcraft/event/forge/ServerLifecycleEvent.java b/forge/src/main/java/dev/dubhe/anvilcraft/event/forge/ServerLifecycleEvent.java index 15463056d..d7b6da46d 100644 --- a/forge/src/main/java/dev/dubhe/anvilcraft/event/forge/ServerLifecycleEvent.java +++ b/forge/src/main/java/dev/dubhe/anvilcraft/event/forge/ServerLifecycleEvent.java @@ -3,9 +3,13 @@ import dev.dubhe.anvilcraft.AnvilCraft; import dev.dubhe.anvilcraft.api.event.forge.DataPackReloadedEvent; import dev.dubhe.anvilcraft.api.event.server.ServerEndDataPackReloadEvent; +import dev.dubhe.anvilcraft.api.power.PowerGrid; import net.minecraft.server.MinecraftServer; import net.minecraft.server.packs.resources.CloseableResourceManager; +import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.server.ServerStartedEvent; +import net.minecraftforge.event.server.ServerStoppedEvent; +import net.minecraftforge.event.server.ServerStoppingEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import org.jetbrains.annotations.NotNull; @@ -24,9 +28,35 @@ public static void serverStarted(@NotNull ServerStartedEvent event) { * @param event 数据包重载事件 */ @SubscribeEvent - public void onDataPackReloaded(@NotNull DataPackReloadedEvent event) { + public static void onDataPackReloaded(@NotNull DataPackReloadedEvent event) { MinecraftServer server = event.getServer(); CloseableResourceManager resourceManager = event.getResourceManager(); AnvilCraft.EVENT_BUS.post(new ServerEndDataPackReloadEvent(server, resourceManager)); } + + /** + * @param event 服务器刻事件 + */ + @SubscribeEvent + public static void onTick(@NotNull TickEvent.ServerTickEvent event) { + if (event.phase != TickEvent.Phase.START) return; + PowerGrid.tickGrid(); + } + + /** + * @param event 服务器关闭事件 + */ + @SubscribeEvent + public static void onServerStopped(@NotNull ServerStoppedEvent event) { + PowerGrid.isServerClosing = false; + PowerGrid.clear(); + } + + /** + * @param event 服务器关闭事件 + */ + @SubscribeEvent + public static void onServerStopping(ServerStoppingEvent event) { + PowerGrid.isServerClosing = true; + } } diff --git a/forge/src/main/java/dev/dubhe/anvilcraft/forge/AnvilCraftForge.java b/forge/src/main/java/dev/dubhe/anvilcraft/forge/AnvilCraftForge.java index 127c19e91..062febe27 100644 --- a/forge/src/main/java/dev/dubhe/anvilcraft/forge/AnvilCraftForge.java +++ b/forge/src/main/java/dev/dubhe/anvilcraft/forge/AnvilCraftForge.java @@ -37,7 +37,6 @@ public AnvilCraftForge() { IBlockHighlightUtil.render(level, Minecraft.getInstance().renderBuffers().bufferSource(), event.getPoseStack(), event.getCamera()); }); - ModLoadingContext.get().registerExtensionPoint( ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory( diff --git a/forge/src/main/java/dev/dubhe/anvilcraft/mixin/forge/LevelChunkMixin.java b/forge/src/main/java/dev/dubhe/anvilcraft/mixin/forge/LevelChunkMixin.java new file mode 100644 index 000000000..77f9f4add --- /dev/null +++ b/forge/src/main/java/dev/dubhe/anvilcraft/mixin/forge/LevelChunkMixin.java @@ -0,0 +1,89 @@ +package dev.dubhe.anvilcraft.mixin.forge; + +import dev.dubhe.anvilcraft.api.event.forge.BlockEntityEvent; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraftforge.common.MinecraftForge; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.Slice; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.Map; + +@Mixin(LevelChunk.class) +public abstract class LevelChunkMixin { + @Shadow + public abstract Level getLevel(); + + @Inject( + method = "setBlockEntity", + at = @At( + value = "INVOKE", + target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;" + ) + ) + private void onLoadBlockEntity(BlockEntity entity, CallbackInfo ci) { + if (this.getLevel().isClientSide) return; + MinecraftForge.EVENT_BUS.post(new BlockEntityEvent.ServerLoad(this.getLevel(), entity)); + } + + @Inject( + method = "setBlockEntity", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/block/entity/BlockEntity;setRemoved()V" + ), + locals = LocalCapture.CAPTURE_FAILEXCEPTION + ) + private void onRemoveBlockEntity(BlockEntity entity, CallbackInfo ci, BlockPos blockPos, BlockEntity entity2) { + if (this.getLevel().isClientSide) return; + MinecraftForge.EVENT_BUS.post(new BlockEntityEvent.ServerUnload(this.getLevel(), entity2)); + } + + @Redirect( + method = "getBlockEntity(" + + "Lnet/minecraft/core/BlockPos;" + + "Lnet/minecraft/world/level/chunk/LevelChunk$EntityCreationType;" + + ")" + + "Lnet/minecraft/world/level/block/entity/BlockEntity;", + at = @At( + value = "INVOKE", + target = "Ljava/util/Map;remove(Ljava/lang/Object;)Ljava/lang/Object;", + ordinal = 1 + ) + ) + private V onRemoveBlockEntity(@NotNull Map map, K key) { + @Nullable final V removed = map.remove(key); + if (!this.getLevel().isClientSide && removed != null) { + if (removed instanceof BlockEntity entity) { + MinecraftForge.EVENT_BUS.post(new BlockEntityEvent.ServerUnload(this.getLevel(), entity)); + } + } + return removed; + } + + @Inject( + method = "removeBlockEntity", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/block/entity/BlockEntity;setRemoved()V" + ), + locals = LocalCapture.CAPTURE_FAILEXCEPTION + ) + private void onRemoveBlockEntity(BlockPos pos, CallbackInfo ci, BlockEntity removed) { + if (this.getLevel().isClientSide) return; + if (removed != null) { + MinecraftForge.EVENT_BUS.post(new BlockEntityEvent.ServerUnload(this.getLevel(), removed)); + } + } +} diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index d9fe5b512..b6d9365f8 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -9,7 +9,7 @@ displayName="${mod_name}" displayURL="${mod_url}" authors="" description="${mod_description}" -logoFile="icon.png" #optional +logoFile="pack.png" #optional #credits="Thanks for this example mod goes to Java" [[dependencies.${mod_id}]] diff --git a/forge/src/main/resources/anvilcraft.mixins.json b/forge/src/main/resources/anvilcraft.mixins.json index c6a970b55..5c77ffa8e 100644 --- a/forge/src/main/resources/anvilcraft.mixins.json +++ b/forge/src/main/resources/anvilcraft.mixins.json @@ -8,6 +8,7 @@ "FallingBlockEntityMixin", "LightningBoltMixin", "MinecraftServerMixin", + "LevelChunkMixin", "PistonMovingBlockEntityMixin" ], "client": [