diff --git a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e index 673b06212..f5be1ff95 100644 --- a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e +++ b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -1,4 +1,4 @@ -// 1.20.4 2024-03-11T02:13:51.6169998 Recipes +// 1.20.4 2024-03-11T22:16:44.4386235 Recipes 4d3128b37a7153882a9324cda49b5069207561c5 data/actuallyadditions/recipes/atomic_reconstructor.json b0367f5012651764931e8b8fd0c5bcca4e8614c0 data/actuallyadditions/recipes/battery_box.json 7e05cd54092b998dfdbd2221235dd52576ec79eb data/actuallyadditions/recipes/black_quartz_block.json @@ -49,6 +49,7 @@ ff81da8a0f6632779414c0512100696a11771814 data/actuallyadditions/recipes/hopping_ 4acb117a6727554073a78ed81bcd2b0b1af53bec data/actuallyadditions/recipes/laser_relay_item_advanced.json 2c37821d291542d4821842501e07bfad38181553 data/actuallyadditions/recipes/lava_factory_casing.json 76f9eb2b859198eec4c50d992c3715633d5109a8 data/actuallyadditions/recipes/lava_factory_controller.json +1e3936f80be1540cd3d6ed570c1ed6381227db7d data/actuallyadditions/recipes/leaf_generator.json 73696fd4e851f440a9850485fc9ad03fc63442a9 data/actuallyadditions/recipes/oil_generator.json 8c78ebb9351b98ffe368391a391b90385c0b8b7f data/actuallyadditions/recipes/placer.json 184acfb5fd3799b3fbe35150c67b6530581f8bf1 data/actuallyadditions/recipes/powered_furnace.json diff --git a/src/generated/resources/data/actuallyadditions/recipes/leaf_generator.json b/src/generated/resources/data/actuallyadditions/recipes/leaf_generator.json new file mode 100644 index 000000000..95a7dcf1a --- /dev/null +++ b/src/generated/resources/data/actuallyadditions/recipes/leaf_generator.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "item": "actuallyadditions:advanced_coil" + }, + "C": { + "item": "actuallyadditions:enori_crystal" + }, + "E": { + "item": "actuallyadditions:empowered_restonia_crystal_block" + }, + "I": { + "item": "actuallyadditions:iron_casing" + }, + "L": { + "tag": "minecraft:leaves" + } + }, + "pattern": [ + "CIC", + "ELE", + "CAC" + ], + "result": { + "item": "actuallyadditions:leaf_generator" + } +} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/BlockRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/BlockRecipeGenerator.java index faa19501e..e0545d488 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/BlockRecipeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/BlockRecipeGenerator.java @@ -399,6 +399,16 @@ public class BlockRecipeGenerator extends RecipeProvider { .define('A', ActuallyItems.ADVANCED_COIL.get()) .define('I', ActuallyBlocks.IRON_CASING.get()) .save(recipeOutput); + + // Leaf-eating Generator + Recipe.shaped(ActuallyBlocks.LEAF_GENERATOR.getItem()) + .pattern("CIC", "ELE", "CAC") + .define('C', ActuallyItems.ENORI_CRYSTAL.get()) + .define('I', ActuallyBlocks.IRON_CASING.get()) + .define('E', ActuallyBlocks.EMPOWERED_RESTONIA_CRYSTAL.get()) + .define('L', ItemTags.LEAVES) + .define('A', ActuallyItems.ADVANCED_COIL.get()) + .save(recipeOutput); } public static class Recipe { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/CommonConfig.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/CommonConfig.java index 8de47c2b6..f0abae4e8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/CommonConfig.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/CommonConfig.java @@ -42,6 +42,9 @@ public class CommonConfig { public static ModConfigSpec.IntValue OIL_GENERATOR_TRANSFER; public static ModConfigSpec.IntValue MINER_LENS_ENERGY; public static ModConfigSpec.BooleanValue LASER_RELAY_LOSS; + public static ModConfigSpec.IntValue LEAF_GENERATOR_COOLDOWN; + public static ModConfigSpec.IntValue LEAF_GENERATOR_CF_PER_LEAF; + public static ModConfigSpec.IntValue LEAF_GENERATOR_AREA; public static void build() { BUILDER.comment("Machine Settings").push("machineSettings"); @@ -51,6 +54,9 @@ public class CommonConfig { OIL_GENERATOR_TRANSFER = BUILDER.comment("The amount of power the oil generator can transfer per tick.").defineInRange("oilGeneratorTransfer", 500, 100, Integer.MAX_VALUE); MINER_LENS_ENERGY = BUILDER.comment("The energy use of the Atomic Reconstructor's Mining Lens.").defineInRange("minerLensEnergy", 60000, 1, Integer.MAX_VALUE); LASER_RELAY_LOSS = BUILDER.comment("If Energy Laser Relays should have energy loss.").define("laserRelayLoss", true); + LEAF_GENERATOR_COOLDOWN = BUILDER.comment("The cooldown between two generation cycles of the Leaf Generator, in ticks").defineInRange("leafGeneratorCooldown", 5, 1, Integer.MAX_VALUE); + LEAF_GENERATOR_CF_PER_LEAF = BUILDER.comment("The Leaf Generator's Energy Production in CF/Leaf").defineInRange("leafGeneratorCPPerLeaf", 300, 1, Integer.MAX_VALUE); + LEAF_GENERATOR_AREA = BUILDER.comment("The size of the Leaf Generator's harvesting area. Default is 7x7x7, must be an odd number.").defineInRange("leafGeneratorArea", 7, 1, Integer.MAX_VALUE); BUILDER.pop(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java index d41c9754e..57c1ba836 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java @@ -11,11 +11,12 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; +import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; +import net.minecraft.tags.BlockTags; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; @@ -24,9 +25,9 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.neoforged.neoforge.energy.IEnergyStorage; -import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; public class TileEntityLeafGenerator extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay { @@ -62,25 +63,19 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE if (!tile.isRedstonePowered) { - if (tile.nextUseCounter >= ConfigIntValues.LEAF_GENERATOR_COOLDOWN.getValue()) { + if (tile.nextUseCounter >= CommonConfig.Machines.LEAF_GENERATOR_COOLDOWN.get()) { tile.nextUseCounter = 0; - int energyProduced = ConfigIntValues.LEAF_GENERATOR_CF_PER_LEAF.getValue(); + int energyProduced = CommonConfig.Machines.LEAF_GENERATOR_CF_PER_LEAF.get(); if (energyProduced > 0 && energyProduced <= tile.storage.getMaxEnergyStored() - tile.storage.getEnergyStored()) { - List breakPositions = new ArrayList<>(); - - int range = ConfigIntValues.LEAF_GENERATOR_AREA.getValue(); - for (int reachX = -range; reachX < range + 1; reachX++) { - for (int reachZ = -range; reachZ < range + 1; reachZ++) { - for (int reachY = -range; reachY < range + 1; reachY++) { - BlockPos offsetPos = pos.offset(reachX, reachY, reachZ); - Block block = level.getBlockState(offsetPos).getBlock(); - if (block instanceof LeavesBlock) { // TODO: [port] validate tile is a good way of checking if something is a leaf - breakPositions.add(offsetPos); - } - } - } - } + int range = CommonConfig.Machines.LEAF_GENERATOR_AREA.get(); + List breakPositions = BlockPos.betweenClosedStream( + pos.offset(-range, -range, -range), + pos.offset(range, range, range)).map(BlockPos::immutable).collect(Collectors.toList()); + breakPositions.removeIf(blockPos -> { + BlockState offsetState = level.getBlockState(blockPos); + return !(offsetState.getBlock() instanceof LeavesBlock || offsetState.is(BlockTags.LEAVES)); + }); if (!breakPositions.isEmpty()) { Collections.shuffle(breakPositions); diff --git a/src/main/resources/assets/actuallyadditions/lang/en_us.json b/src/main/resources/assets/actuallyadditions/lang/en_us.json index d26ae103c..d8e4d8659 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_us.json +++ b/src/main/resources/assets/actuallyadditions/lang/en_us.json @@ -170,7 +170,7 @@ "block.actuallyadditions.flax": "Flax Plant", "block.actuallyadditions.coffee_machine": "Coffee Maker", "block.actuallyadditions.xp_solidifier": "Experience Solidifier", - "block.actuallyadditions.leaf_generator": "Leaf-Eating Generator (wip)", + "block.actuallyadditions.leaf_generator": "Leaf-Eating Generator", "block.actuallyadditions.long_range_breaker": "Long-Range Breaker (wip)", "block.actuallyadditions.ranged_collector": "Ranged Collector", "block.actuallyadditions.laser_relay": "Energy Laser Relay (wip)",