From 9eb4cf117c042538e813ee59d9d41997f96ff7f0 Mon Sep 17 00:00:00 2001 From: jottyfan Date: Thu, 30 Jul 2020 23:03:00 +0200 Subject: [PATCH] speedpowdertools work --- .../quickiefabric/blocks/QuickieBlocks.java | 1 + .../quickiefabric/event/EventBlockBreak.java | 3 +- .../quickiefabric/init/RegistryManager.java | 33 +++++++++++------ .../quickiefabric/tools/QuickieTools.java | 2 ++ .../quickiefabric/tools/ToolRangeable.java | 35 ++----------------- .../quickiefabric/tools/ToolRangeableAxe.java | 2 +- 6 files changed, 30 insertions(+), 46 deletions(-) diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/blocks/QuickieBlocks.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/blocks/QuickieBlocks.java index 717b7fc..4c4e228 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/blocks/QuickieBlocks.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/blocks/QuickieBlocks.java @@ -5,6 +5,7 @@ package de.jottyfan.minecraft.quickiefabric.blocks; * */ public class QuickieBlocks { + public static final BlockDirtSalpeter DIRT_SALPETER = new BlockDirtSalpeter(); public static final BlockOreNetherSulphor ORE_NETHER_SULPHOR = new BlockOreNetherSulphor(); public static final BlockOreSalpeter ORE_SALPETER = new BlockOreSalpeter(); public static final BlockOreSandSalpeter ORE_SAND_SALPETER = new BlockOreSandSalpeter(); diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/event/EventBlockBreak.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/event/EventBlockBreak.java index b837575..7c33295 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/event/EventBlockBreak.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/event/EventBlockBreak.java @@ -106,9 +106,8 @@ public class EventBlockBreak { if (tool.canBreakNeigbbors(blockState)) { Block currentBlock = blockState.getBlock(); if (validBlocks.contains(currentBlock)) { - Block.dropStacks(blockState, world, pos); + Block.dropStacks(blockState, world, pos); // includes xorbs world.setBlockState(pos, Blocks.AIR.getDefaultState()); - currentBlock.onStacksDropped(blockState, world, pos, stack); if (range == null || range.getxRange() > 1 || range.getyRange() > 1 || range.getzRange() > 1) { HarvestRange nextRadius = range == null ? null : range.addXYZ(-1); breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north(), tool, nextRadius, blockBreakDirection, player); diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/init/RegistryManager.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/init/RegistryManager.java index e59e182..040ddeb 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/init/RegistryManager.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/init/RegistryManager.java @@ -29,6 +29,7 @@ import net.minecraft.world.gen.decorator.RangeDecoratorConfig; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.OreFeatureConfig; import net.minecraft.world.gen.feature.OreFeatureConfig.Target; +import net.minecraft.world.gen.feature.SimpleBlockFeatureConfig; /** * @@ -47,6 +48,9 @@ public class RegistryManager { stacks.add(new ItemStack(QuickieItems.LEVELUP)); stacks.add(new ItemStack(QuickieItems.PENCIL)); stacks.add(new ItemStack(QuickieTools.SPEEDPOWDERAXE)); + stacks.add(new ItemStack(QuickieTools.SPEEDPOWDERPICKAXE)); + stacks.add(new ItemStack(QuickieTools.SPEEDPOWDERSHOVEL)); + stacks.add(new ItemStack(QuickieBlocks.DIRT_SALPETER)); stacks.add(new ItemStack(QuickieBlocks.ORE_NETHER_SULPHOR)); stacks.add(new ItemStack(QuickieBlocks.ORE_SALPETER)); stacks.add(new ItemStack(QuickieBlocks.ORE_SAND_SALPETER)); @@ -65,6 +69,7 @@ public class RegistryManager { public static final void registerBlocks() { LOGGER.debug("registering quickiefabric blocks"); + registerBlock(QuickieBlocks.DIRT_SALPETER, "dirtsalpeter"); registerBlock(QuickieBlocks.ORE_NETHER_SULPHOR, "orenethersulphor"); registerBlock(QuickieBlocks.ORE_SALPETER, "oresalpeter"); registerBlock(QuickieBlocks.ORE_SAND_SALPETER, "oresandsalpeter"); @@ -114,13 +119,19 @@ public class RegistryManager { biome.addFeature(GenerationStep.Feature.UNDERGROUND_ORES, Feature.ORE.configure(ofc).createDecoratedFeature(Decorator.COUNT_RANGE.configure(rdc))); } - public static void generateOreForBlocks(Biome biome, List placeOn, List placeIn, List placeUnder, Block block, int nrPerChunk, - int minHeight, int maxHeightBase, int maxHeight) { - // TODO -// BlockWithContextConfig config = new BlockWithContextConfig(block.getDefaultState(), placeOn, placeIn, placeUnder); -// RangeDecoratorConfig rdc = new RangeDecoratorConfig(nrPerChunk, minHeight, maxHeightBase, maxHeight); -// ConfiguredPlacement placement = Placement.COUNT_RANGE.configure(rdc); -// biome.addFeature(GenerationStep.Feature.UNDERGROUND_ORES, Feature.SIMPLE_BLOCK.configure(config).withPlacement(placement)); + /** + * generate ore instead of block + * + * @param biome the biome + * @param placeOn the list of blockStates underneath + * @param placeIn the list of blockStates to be replaced + * @param placeUnder the list of blockStates above + * @param block the block to set + * @param chance the chance for the replacement + */ + public static void generateOreForBlocks(Biome biome, List placeOn, List placeIn, List placeUnder, Block block, float chance) { + SimpleBlockFeatureConfig sbfc = new SimpleBlockFeatureConfig(block.getDefaultState(), placeOn, placeIn, placeUnder); + biome.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS, Feature.SIMPLE_BLOCK.configure(sbfc).withChance(chance).feature); } @@ -133,7 +144,7 @@ public class RegistryManager { public static final void handleBiome(Biome biome) { if (biome.getCategory() == Biome.Category.NETHER) { RegistryManager.generateOreForTarget(biome, OreFeatureConfig.Target.NETHER_ORE_REPLACEABLES, QuickieBlocks.ORE_NETHER_SULPHOR, 24, 10, 0, 0, 128); - } else if (biome.getCategory() != Biome.Category.THEEND) { + } else if (biome.getCategory() == Biome.Category.THEEND) { } else { List sandlike = new ArrayList<>(); sandlike.add(Blocks.SAND.getDefaultState()); @@ -142,8 +153,10 @@ public class RegistryManager { sandlike.add(Blocks.CHISELED_SANDSTONE.getDefaultState()); List dirtlike = new ArrayList<>(); dirtlike.add(Blocks.DIRT.getDefaultState()); - RegistryManager.generateOreForBlocks(biome, sandlike, sandlike, sandlike, QuickieBlocks.SAND_SALPETER, 10, 64, 196, 255); - RegistryManager.generateOreForBlocks(biome, sandlike, sandlike, sandlike, QuickieBlocks.ORE_SAND_SALPETER, 10, 64, 196, 255); + dirtlike.add(Blocks.GRASS.getDefaultState()); + RegistryManager.generateOreForBlocks(biome, dirtlike, dirtlike, dirtlike, QuickieBlocks.DIRT_SALPETER, 1.0f); + RegistryManager.generateOreForBlocks(biome, sandlike, sandlike, sandlike, QuickieBlocks.SAND_SALPETER, 1.0f); + RegistryManager.generateOreForBlocks(biome, sandlike, sandlike, sandlike, QuickieBlocks.ORE_SAND_SALPETER, 1.0f); RegistryManager.generateOreForTarget(biome, OreFeatureConfig.Target.NATURAL_STONE, QuickieBlocks.ORE_SULPHOR, 16, 4, 4, 196, 255); RegistryManager.generateOreForTarget(biome, OreFeatureConfig.Target.NATURAL_STONE, QuickieBlocks.ORE_SALPETER, 12, 10, 4, 196, 255); } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/QuickieTools.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/QuickieTools.java index 9634855..a6a56cc 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/QuickieTools.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/QuickieTools.java @@ -7,4 +7,6 @@ package de.jottyfan.minecraft.quickiefabric.tools; */ public class QuickieTools { public static final ToolSpeedpowderAxe SPEEDPOWDERAXE = new ToolSpeedpowderAxe(); + public static final ToolSpeedpowderPickaxe SPEEDPOWDERPICKAXE = new ToolSpeedpowderPickaxe(); + public static final ToolSpeedpowderShovel SPEEDPOWDERSHOVEL = new ToolSpeedpowderShovel(); } diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java index f0485a2..5936d04 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeable.java @@ -1,8 +1,6 @@ package de.jottyfan.minecraft.quickiefabric.tools; -import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; import java.util.List; import java.util.Set; @@ -12,7 +10,6 @@ import com.google.common.collect.Sets; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.util.Identifier; /** * @@ -23,7 +20,7 @@ public interface ToolRangeable { public static final Set SHOVEL_EFFECTIVE_ON = Sets.newHashSet(new Block[] { Blocks.GRAVEL, Blocks.SAND, Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.CLAY, Blocks.FARMLAND, Blocks.GRASS_PATH, Blocks.RED_SAND, Blocks.SOUL_SAND }); - public static final List> AXE_BLOCKLISTS = Lists.newArrayList( + public static final List> AXE_EFFECTIVE_ON = Lists.newArrayList( Arrays.asList(Blocks.ACACIA_LOG, Blocks.STRIPPED_ACACIA_LOG, Blocks.ACACIA_WOOD, Blocks.STRIPPED_ACACIA_WOOD), Arrays.asList(Blocks.BIRCH_LOG, Blocks.STRIPPED_BIRCH_LOG, Blocks.BIRCH_WOOD, Blocks.STRIPPED_BIRCH_WOOD), Arrays.asList(Blocks.DARK_OAK_LOG, Blocks.STRIPPED_DARK_OAK_LOG, Blocks.DARK_OAK_WOOD, @@ -41,35 +38,7 @@ public interface ToolRangeable { Blocks.MUSHROOM_STEM), Arrays.asList(Blocks.POTTED_RED_MUSHROOM, Blocks.RED_MUSHROOM_BLOCK, Blocks.RED_MUSHROOM, Blocks.MUSHROOM_STEM)); - public static final Set PICKAXE_BLOCKLISTS = Sets.newHashSet(new Block[] {Blocks.GLOWSTONE}); - - public static final Set BIOMESOPLENTY_SHOVEL = Sets - .newHashSet(new Identifier[] { new Identifier("biomesoplenty", "flesh"), - new Identifier("biomesoplenty", "dirt"), new Identifier("biomesoplenty", "grass"), - new Identifier("biomesoplenty", "mud"), new Identifier("biomesoplenty", "white_sand") }); - - public static final Set BIOMESOPLENTY_PICKAXE = Sets - .newHashSet(new Identifier[] { new Identifier("biomesoplenty", "dried_sand") }); - - public static final List> BIOMESOPLENTY_AXE = Lists.newArrayList(generateBOPAxeSet()); - - static List> generateBOPAxeSet() { - List> list = new ArrayList<>(); - String[] bOPLogs = new String[] { "cherry", "dead", "ethereal", "fir", "hellbark", "jacaranda", "magic", "mahogany", - "palm", "redwood", "umbran", "willow" }; - for (String s : bOPLogs) { - Set set = new HashSet<>(); - set.add(new Identifier("biomesoplenty", s + "_log")); - set.add(new Identifier("biomesoplenty", s + "_wood")); - set.add(new Identifier("biomesoplenty", "stripped_" + s + "_log")); - set.add(new Identifier("biomesoplenty", "stripped_" + s + "_wood")); - list.add(set); - list.add(Sets.newHashSet(new Identifier("biomesoplenty", s + "_stairs"))); - list.add(Sets.newHashSet(new Identifier("biomesoplenty", s + "_planks"))); - list.add(Sets.newHashSet(new Identifier("biomesoplenty", s + "_slab"))); - } - return list; - } + public static final Set PICKAXE_EFFECTIVE_ON = Sets.newHashSet(new Block[] {Blocks.GLOWSTONE}); /** * @return range of blocks to be harvested diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java index a93ae78..739825e 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/tools/ToolRangeableAxe.java @@ -115,7 +115,7 @@ public class ToolRangeableAxe extends AxeItem implements ToolRangeable { @Override public List getBlockList(Block block) { - for (List blockList : AXE_BLOCKLISTS) { + for (List blockList : AXE_EFFECTIVE_ON) { if (blockList.contains(block)) { return blockList; }