Long Range Breaker and Vertical Digger

This commit is contained in:
Mrbysco 2024-03-12 18:00:23 +01:00
parent 8419cc67aa
commit 17d8dcce82
10 changed files with 69 additions and 39 deletions

View file

@ -1,4 +1,4 @@
// 1.20.4 2024-03-12T17:11:30.554907 Recipes // 1.20.4 2024-03-12T17:59:34.1573737 Recipes
4d3128b37a7153882a9324cda49b5069207561c5 data/actuallyadditions/recipes/atomic_reconstructor.json 4d3128b37a7153882a9324cda49b5069207561c5 data/actuallyadditions/recipes/atomic_reconstructor.json
b0367f5012651764931e8b8fd0c5bcca4e8614c0 data/actuallyadditions/recipes/battery_box.json b0367f5012651764931e8b8fd0c5bcca4e8614c0 data/actuallyadditions/recipes/battery_box.json
dba5d4a1a79489d5766fad32f912ab1a64618854 data/actuallyadditions/recipes/bio_reactor.json dba5d4a1a79489d5766fad32f912ab1a64618854 data/actuallyadditions/recipes/bio_reactor.json
@ -53,10 +53,11 @@ ff81da8a0f6632779414c0512100696a11771814 data/actuallyadditions/recipes/hopping_
2c37821d291542d4821842501e07bfad38181553 data/actuallyadditions/recipes/lava_factory_casing.json 2c37821d291542d4821842501e07bfad38181553 data/actuallyadditions/recipes/lava_factory_casing.json
76f9eb2b859198eec4c50d992c3715633d5109a8 data/actuallyadditions/recipes/lava_factory_controller.json 76f9eb2b859198eec4c50d992c3715633d5109a8 data/actuallyadditions/recipes/lava_factory_controller.json
1e3936f80be1540cd3d6ed570c1ed6381227db7d data/actuallyadditions/recipes/leaf_generator.json 1e3936f80be1540cd3d6ed570c1ed6381227db7d data/actuallyadditions/recipes/leaf_generator.json
11a57ce2eea04fed226a817a3995acd406bb2efb data/actuallyadditions/recipes/long_range_breaker.json
73696fd4e851f440a9850485fc9ad03fc63442a9 data/actuallyadditions/recipes/oil_generator.json 73696fd4e851f440a9850485fc9ad03fc63442a9 data/actuallyadditions/recipes/oil_generator.json
afbee3f7074b7aa88d4bc8941d820d02b827da4b data/actuallyadditions/recipes/phantom_booster.json afbee3f7074b7aa88d4bc8941d820d02b827da4b data/actuallyadditions/recipes/phantom_booster.json
f0a9c8a0de8fb884cd207c34c4a10e7a4a021153 data/actuallyadditions/recipes/phantom_energyface.json f0a9c8a0de8fb884cd207c34c4a10e7a4a021153 data/actuallyadditions/recipes/phantom_energyface.json
472521d8bb5db8f9165ac642c3309d2d2b48f8e6 data/actuallyadditions/recipes/phantom_itemface.json c7b65084e855bd7f083819ed9339320577510c6f data/actuallyadditions/recipes/phantom_itemface.json
6d3aa070e0fccbb126c80323423c9482259dd6de data/actuallyadditions/recipes/phantom_liquiface.json 6d3aa070e0fccbb126c80323423c9482259dd6de data/actuallyadditions/recipes/phantom_liquiface.json
253e31ad471e2a8e20bfbe077826a8fac35fcc84 data/actuallyadditions/recipes/phantom_redstoneface.json 253e31ad471e2a8e20bfbe077826a8fac35fcc84 data/actuallyadditions/recipes/phantom_redstoneface.json
8c78ebb9351b98ffe368391a391b90385c0b8b7f data/actuallyadditions/recipes/placer.json 8c78ebb9351b98ffe368391a391b90385c0b8b7f data/actuallyadditions/recipes/placer.json

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"A": {
"item": "actuallyadditions:breaker"
},
"V": {
"item": "actuallyadditions:void_crystal"
}
},
"pattern": [
"AAA",
" V "
],
"result": {
"item": "actuallyadditions:long_range_breaker"
}
}

View file

@ -416,9 +416,9 @@ public class BlockRecipeGenerator extends RecipeProvider {
// Phantom Itemface // Phantom Itemface
Recipe.shaped(ActuallyBlocks.PHANTOM_ITEMFACE.getItem()) Recipe.shaped(ActuallyBlocks.PHANTOM_ITEMFACE.getItem())
.pattern(" C ", "DED", " A ") .pattern(" C ", "MEM", " A ")
.define('C', Tags.Items.CHESTS_WOODEN) .define('C', Tags.Items.CHESTS_WOODEN)
.define('D', ActuallyItems.EMPOWERED_DIAMATINE_CRYSTAL) .define('M', Items.PHANTOM_MEMBRANE)
.define('E', ActuallyBlocks.ENDER_CASING.get()) .define('E', ActuallyBlocks.ENDER_CASING.get())
.define('A', ActuallyItems.ADVANCED_COIL.get()) .define('A', ActuallyItems.ADVANCED_COIL.get())
.save(recipeOutput); .save(recipeOutput);
@ -479,6 +479,13 @@ public class BlockRecipeGenerator extends RecipeProvider {
.define('E', ActuallyItems.ENORI_CRYSTAL) .define('E', ActuallyItems.ENORI_CRYSTAL)
.define('C', ActuallyBlocks.IRON_CASING.get()) .define('C', ActuallyBlocks.IRON_CASING.get())
.save(recipeOutput); .save(recipeOutput);
// Long-Range Breaker
Recipe.shaped(ActuallyBlocks.LONG_RANGE_BREAKER.getItem())
.pattern("AAA", " V ")
.define('A', ActuallyBlocks.BREAKER.get())
.define('V', ActuallyItems.VOID_CRYSTAL)
.save(recipeOutput);
} }
public static class Recipe { public static class Recipe {

View file

@ -45,6 +45,8 @@ public class CommonConfig {
public static ModConfigSpec.IntValue LEAF_GENERATOR_COOLDOWN; public static ModConfigSpec.IntValue LEAF_GENERATOR_COOLDOWN;
public static ModConfigSpec.IntValue LEAF_GENERATOR_CF_PER_LEAF; public static ModConfigSpec.IntValue LEAF_GENERATOR_CF_PER_LEAF;
public static ModConfigSpec.IntValue LEAF_GENERATOR_AREA; public static ModConfigSpec.IntValue LEAF_GENERATOR_AREA;
public static ModConfigSpec.ConfigValue<List<? extends String>> MINER_EXTRA_WHITELIST;
public static ModConfigSpec.ConfigValue<List<? extends String>> MINER_BLACKLIST;
public static void build() { public static void build() {
BUILDER.comment("Machine Settings").push("machineSettings"); BUILDER.comment("Machine Settings").push("machineSettings");
@ -57,6 +59,12 @@ public class CommonConfig {
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_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_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); 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);
MINER_EXTRA_WHITELIST = BUILDER
.comment("By default, the Vertical Digger mines everything that is in the 'forge:ores' block/item tags. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command. This Config Option only applies if the miner is in Ores Only Mode.")
.defineListAllowEmpty("Vertical Digger Extra Whitelist", new ArrayList<>(), (o) -> o instanceof String);
MINER_BLACKLIST = BUILDER
.comment("By default, the Vertical Digger mines everything that is in the 'forge:ores' block/item tags. If there is one that it can mine, but shouldn't be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command. This Config Option will apply in both modes.")
.defineListAllowEmpty("Vertical Digger Blacklist", new ArrayList<>(), (o) -> o instanceof String);
BUILDER.pop(); BUILDER.pop();
} }

View file

@ -12,9 +12,11 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerMiner; import de.ellpeck.actuallyadditions.mod.inventory.ContainerMiner;
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityVerticalDigger; import de.ellpeck.actuallyadditions.mod.tile.TileEntityVerticalDigger;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
@ -39,13 +41,12 @@ public class GuiMiner extends AAScreen<ContainerMiner> {
public void init() { public void init() {
super.init(); super.init();
// Button buttonMode = new Button(this.leftPos + this.imageWidth / 2 - 51, this.topPos + 75, 50, 20, "Mode", button -> { this.addRenderableWidget(Button.builder(Component.literal("Mode"), $ -> {
// }); PacketHandlerHelper.sendButtonPacket(this.miner, 0);
// this.addButton(buttonMode); }).bounds(this.leftPos + this.imageWidth / 2 - 51, this.topPos + 75, 50, 20).build());
// this.addRenderableWidget(Button.builder(Component.literal("Reset"), $ -> {
// Button buttonReset = new Button(this.leftPos + this.imageWidth / 2 + 1, this.topPos + 75, 50, 20, "Reset", button -> { PacketHandlerHelper.sendButtonPacket(this.miner, 1);
// }); }).bounds(this.leftPos + this.imageWidth / 2 + 1, this.topPos + 75, 50, 20).build());
// this.addButton(buttonReset);
} }
@Override @Override
public void renderBg(GuiGraphics guiGraphics, float f, int x, int y) { public void renderBg(GuiGraphics guiGraphics, float f, int x, int y) {
@ -60,9 +61,4 @@ public class GuiMiner extends AAScreen<ContainerMiner> {
: "Mining Everything"; : "Mining Everything";
guiGraphics.drawString(font, mining, this.leftPos + this.imageWidth / 2 - this.font.width(mining) / 2, this.topPos + 8, 0x404040, false); guiGraphics.drawString(font, mining, this.leftPos + this.imageWidth / 2 - this.font.width(mining) / 2, this.topPos + 8, 0x404040, false);
} }
// @Override
// public void actionPerformed(Button button) {
// PacketHandlerHelper.sendButtonPacket(this.miner, button.id);
// }
} }

View file

@ -90,7 +90,7 @@ public class ItemWingsOfTheBats extends ItemBase {
if (event.getEntity().level() != null && !event.getEntity().level().isClientSide && source instanceof Player) { if (event.getEntity().level() != null && !event.getEntity().level().isClientSide && source instanceof Player) {
//Drop Wings from Bats //Drop Wings from Bats
if (ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntity() instanceof Bat) { if (ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntity() instanceof Bat) { //TODO: Change to CommonConfig
int looting = event.getLootingLevel(); int looting = event.getLootingLevel();
Iterable<ItemStack> equip = source.getHandSlots(); Iterable<ItemStack> equip = source.getHandSlots();

View file

@ -145,7 +145,7 @@ public class TileEntityLongRangeBreaker extends TileEntityInventoryBase implemen
@Override @Override
public Component getDisplayName() { public Component getDisplayName() {
return Component.empty(); return Component.translatable("container.actuallyadditions.directionalBreaker");
} }
@Nullable @Nullable

View file

@ -11,7 +11,7 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerMiner; import de.ellpeck.actuallyadditions.mod.inventory.ContainerMiner;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
@ -37,6 +37,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.common.Tags;
import net.neoforged.neoforge.common.TierSortingRegistry; import net.neoforged.neoforge.common.TierSortingRegistry;
import net.neoforged.neoforge.common.util.FakePlayerFactory; import net.neoforged.neoforge.common.util.FakePlayerFactory;
import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.energy.IEnergyStorage;
@ -145,7 +146,7 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements
ItemStack stack = block.getCloneItemStack(state, new BlockHitResult(new Vec3(0, 0, 0), Direction.DOWN, pos, false), this.level, pos, FakePlayerFactory.getMinecraft((ServerLevel) this.level)); ItemStack stack = block.getCloneItemStack(state, new BlockHitResult(new Vec3(0, 0, 0), Direction.DOWN, pos, false), this.level, pos, FakePlayerFactory.getMinecraft((ServerLevel) this.level));
if (!state.isAir()) { if (!state.isAir()) {
//block.getHarvestLevel(state) <= DrillItem.HARVEST_LEVEL //block.getHarvestLevel(state) <= DrillItem.HARVEST_LEVEL
if (TierSortingRegistry.isCorrectTierForDrops(Tiers.NETHERITE, state) && state.getDestroySpeed(this.level, pos) >= 0F && !(block instanceof IFluidBlock) && this.isMinable(block, stack)) { if (TierSortingRegistry.isCorrectTierForDrops(Tiers.NETHERITE, state) && state.getDestroySpeed(this.level, pos) >= 0F && !(block instanceof IFluidBlock) && this.isMinable(state, stack)) {
List<ItemStack> drops = Block.getDrops(state, (ServerLevel) this.level, pos, this.level.getBlockEntity(pos)); List<ItemStack> drops = Block.getDrops(state, (ServerLevel) this.level, pos, this.level.getBlockEntity(pos));
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.level, pos); float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.level, pos);
@ -170,26 +171,20 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements
return false; return false;
} }
private boolean isMinable(Block block, ItemStack stack) { private boolean isMinable(BlockState state, ItemStack stack) {
if (block != null) { Block block = state.getBlock();
if (!state.isEmpty()) {
if (!this.isBlacklisted(block)) { if (!this.isBlacklisted(block)) {
if (!this.onlyMineOres) { if (!this.onlyMineOres) {
return true; return true;
} else { } else {
if (StackUtil.isValid(stack)) { if (!stack.isEmpty()) {
// TODO: [port] come back and see if there is a tag for this if (stack.is(Tags.Items.ORES) || state.is(Tags.Blocks.ORES)) { // Check both the block and item tags
return true;
// int[] ids = OreDictionary.getOreIDs(stack); }
// for (int id : ids) {
// String name = OreDictionary.getOreName(id);
// if (name.startsWith("ore") || name.startsWith("denseore")) {
// return true;
// }
// }
String reg = BuiltInRegistries.BLOCK.getKey(block).toString(); String reg = BuiltInRegistries.BLOCK.getKey(block).toString();
if (!reg.isEmpty()) { if (!reg.isEmpty()) {
for (String string : ConfigStringListValues.MINER_EXTRA_WHITELIST.getValue()) { for (String string : CommonConfig.Machines.MINER_EXTRA_WHITELIST.get()) {
if (reg.equals(string)) { if (reg.equals(string)) {
return true; return true;
} }
@ -210,7 +205,7 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements
private boolean isBlacklisted(Block block) { private boolean isBlacklisted(Block block) {
String reg = BuiltInRegistries.BLOCK.getKey(block).toString(); String reg = BuiltInRegistries.BLOCK.getKey(block).toString();
if (!reg.isEmpty()) { if (!reg.isEmpty()) {
for (String string : ConfigStringListValues.MINER_BLACKLIST.getValue()) { for (String string : CommonConfig.Machines.MINER_BLACKLIST.get()) {
if (reg.equals(string)) { if (reg.equals(string)) {
return true; return true;
} }
@ -253,7 +248,7 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements
@Override @Override
public Component getDisplayName() { public Component getDisplayName() {
return Component.empty(); return Component.translatable("container.actuallyadditions.vertical_digger");
} }
@Nullable @Nullable

View file

@ -37,6 +37,8 @@ import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.common.util.FakePlayer; import net.neoforged.neoforge.common.util.FakePlayer;
import net.neoforged.neoforge.common.util.FakePlayerFactory; import net.neoforged.neoforge.common.util.FakePlayerFactory;
import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.energy.IEnergyStorage;
import net.neoforged.neoforge.event.EventHooks;
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
import net.neoforged.neoforge.event.level.BlockEvent.BreakEvent; import net.neoforged.neoforge.event.level.BlockEvent.BreakEvent;
import net.neoforged.neoforge.fluids.FluidStack; import net.neoforged.neoforge.fluids.FluidStack;
import net.neoforged.neoforge.fluids.capability.IFluidHandler; import net.neoforged.neoforge.fluids.capability.IFluidHandler;
@ -259,7 +261,9 @@ public final class WorldUtil {
BlockState state = level.getBlockState(pos); BlockState state = level.getBlockState(pos);
BreakEvent event = new BreakEvent(level, pos, state, fake); BreakEvent event = new BreakEvent(level, pos, state, fake);
if (!NeoForge.EVENT_BUS.post(event).isCanceled()) { NeoForge.EVENT_BUS.post(event);
if (!event.isCanceled()) {
return EventHooks.doPlayerHarvestCheck(fake, state, true) ? 1F : 0F;
//return ForgeEventFactory.fireBlockHarvesting(drops, world, pos, state, 0, 1, false, fake); //TODO what?! //return ForgeEventFactory.fireBlockHarvesting(drops, world, pos, state, 0, 1, false, fake); //TODO what?!
} }
} }

View file

@ -171,7 +171,7 @@
"block.actuallyadditions.coffee_machine": "Coffee Maker", "block.actuallyadditions.coffee_machine": "Coffee Maker",
"block.actuallyadditions.xp_solidifier": "Experience Solidifier", "block.actuallyadditions.xp_solidifier": "Experience Solidifier",
"block.actuallyadditions.leaf_generator": "Leaf-Eating Generator", "block.actuallyadditions.leaf_generator": "Leaf-Eating Generator",
"block.actuallyadditions.long_range_breaker": "Long-Range Breaker (wip)", "block.actuallyadditions.long_range_breaker": "Long-Range Breaker",
"block.actuallyadditions.ranged_collector": "Ranged Collector", "block.actuallyadditions.ranged_collector": "Ranged Collector",
"block.actuallyadditions.laser_relay": "Energy Laser Relay (wip)", "block.actuallyadditions.laser_relay": "Energy Laser Relay (wip)",
"block.actuallyadditions.laser_relay_advanced": "Advanced Energy Laser Relay (wip)", "block.actuallyadditions.laser_relay_advanced": "Advanced Energy Laser Relay (wip)",
@ -193,7 +193,7 @@
"block.actuallyadditions.empowered_emeradic_crystal_block": "Empowered Emeradic Crystal Block", "block.actuallyadditions.empowered_emeradic_crystal_block": "Empowered Emeradic Crystal Block",
"block.actuallyadditions.empowered_void_crystal_block": "Empowered Void Crystal Block", "block.actuallyadditions.empowered_void_crystal_block": "Empowered Void Crystal Block",
"block.actuallyadditions.empowered_enori_crystal_block": "Empowered Enori Crystal Block", "block.actuallyadditions.empowered_enori_crystal_block": "Empowered Enori Crystal Block",
"block.actuallyadditions.vertical_digger": "Vertical Digger (wip)", "block.actuallyadditions.vertical_digger": "Vertical Digger",
"block.actuallyadditions.firework_box": "Firework Box", "block.actuallyadditions.firework_box": "Firework Box",
"block.actuallyadditions.black_quartz_wall": "Black Quartz Wall", "block.actuallyadditions.black_quartz_wall": "Black Quartz Wall",
"block.actuallyadditions.black_quartz_stair": "Black Quartz Stairs", "block.actuallyadditions.black_quartz_stair": "Black Quartz Stairs",