added quickiepowder hoes

This commit is contained in:
Jottyfan 2023-11-26 21:23:24 +01:00
parent a0252d4608
commit 3dcf5e09e4
16 changed files with 216 additions and 100 deletions

View File

@ -9,7 +9,7 @@ yarn_mappings=1.20.3-pre2+build.5
loader_version=0.14.24
# Mod Properties
mod_version = 1.20.3.2
mod_version = 1.20.3.3
maven_group = de.jottyfan.minecraft
archives_base_name = quickiefabric

View File

@ -81,6 +81,9 @@ public class EventBlockBreak {
} else if (QuickieTools.QUICKIEPOWDERSHOVEL.equals(tool)) {
return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
player, false);
} else if (QuickieTools.QUICKIEPOWDERHOE.equals(tool)) {
return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
player, false);
} else {
return 0;
}

View File

@ -110,6 +110,8 @@ public class RegistryManager {
stacks.add(new ItemStack(QuickieTools.QUICKIEPOWDERAXE));
stacks.add(new ItemStack(QuickieTools.QUICKIEPOWDERPICKAXE));
stacks.add(new ItemStack(QuickieTools.QUICKIEPOWDERSHOVEL));
stacks.add(new ItemStack(QuickieTools.QUICKIEPOWDERHOE));
stacks.add(new ItemStack(QuickieTools.QUICKIEPOWDERWATERHOE));
stacks.add(new ItemStack(QuickieBlocks.DIRT_SALPETER));
stacks.add(new ItemStack(QuickieBlocks.ORE_NETHER_SULPHOR));
stacks.add(new ItemStack(QuickieBlocks.ORE_SALPETER));
@ -271,6 +273,8 @@ public class RegistryManager {
registerItem(QuickieTools.QUICKIEPOWDERAXE, "quickiepowderaxe");
registerItem(QuickieTools.QUICKIEPOWDERPICKAXE, "quickiepowderpickaxe");
registerItem(QuickieTools.QUICKIEPOWDERSHOVEL, "quickiepowdershovel");
registerItem(QuickieTools.QUICKIEPOWDERHOE, "quickiepowderhoe");
registerItem(QuickieTools.QUICKIEPOWDERWATERHOE, "quickiepowderwaterhoe");
}
public static final void registerContainer() {

View File

@ -14,4 +14,6 @@ public class QuickieTools {
public static final ToolQuickiepowderAxe QUICKIEPOWDERAXE = new ToolQuickiepowderAxe();
public static final ToolQuickiepowderPickaxe QUICKIEPOWDERPICKAXE = new ToolQuickiepowderPickaxe();
public static final ToolQuickiepowderShovel QUICKIEPOWDERSHOVEL = new ToolQuickiepowderShovel();
public static final ToolQuickiepowderHoe QUICKIEPOWDERHOE = new ToolQuickiepowderHoe();
public static final ToolQuickiepowderWaterHoe QUICKIEPOWDERWATERHOE = new ToolQuickiepowderWaterHoe();
}

View File

@ -0,0 +1,18 @@
package de.jottyfan.minecraft.quickiefabric.tools;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.item.ToolMaterials;
/**
*
* @author jotty
*
*/
public class ToolQuickiepowderHoe extends ToolRangeableHoe {
public static final Integer DEFAULT_PLOW_RANGE = 4;
public ToolQuickiepowderHoe() {
super(ToolMaterials.DIAMOND, 4, 2.0f, new FabricItemSettings(), new HarvestRange(DEFAULT_PLOW_RANGE));
}
}

View File

@ -0,0 +1,34 @@
package de.jottyfan.minecraft.quickiefabric.tools;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class ToolQuickiepowderWaterHoe extends ToolQuickiepowderHoe {
@Override
public ActionResult useOnBlock(ItemUsageContext context) {
ActionResult res = super.useOnBlock(context);
if (!ActionResult.PASS.equals(res)) {
BlockPos pos = context.getBlockPos();
World world = context.getWorld();
world.setBlockState(pos, Blocks.WATER.getDefaultState());
Hand hand = context.getHand();
PlayerEntity player = context.getPlayer();
ItemStack oldTool = player.getStackInHand(hand);
ItemStack newTool = new ItemStack(QuickieTools.QUICKIEPOWDERHOE);
newTool.setDamage(oldTool.getDamage());
player.setStackInHand(hand, newTool);
}
return res;
}
}

View File

@ -0,0 +1,97 @@
package de.jottyfan.minecraft.quickiefabric.tools;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.CropBlock;
import net.minecraft.item.HoeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.item.ToolMaterial;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public abstract class ToolRangeableHoe extends HoeItem implements ToolRangeable {
public HarvestRange range;
public ToolRangeableHoe(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings, HarvestRange range) {
super(material, attackDamage, attackSpeed, settings);
this.range = range;
}
@Override
public ActionResult useOnBlock(ItemUsageContext context) {
ActionResult res = super.useOnBlock(context);
boolean isCrop = context.getWorld().getBlockState(context.getBlockPos()).getBlock() instanceof CropBlock;
if (!ActionResult.PASS.equals(res) || isCrop) {
for (int x = -this.range.getxRange(); x <= this.range.getxRange(); x++) {
for (int y = -this.range.getyRange(); y <= this.range.getyRange(); y++) {
for (int z = -this.range.getzRange(); z <= this.range.getzRange(); z++) {
if (!isCrop) {
removePossibleGrass(context.getWorld(), new BlockPos(x, y, z));
BlockHitResult bhr = new BlockHitResult(context.getHitPos(), Direction.UP,
context.getBlockPos().add(new Vec3i(x, y, z)), isDamageable());
ItemUsageContext ctx = new ItemUsageContext(context.getPlayer(), context.getHand(), bhr);
super.useOnBlock(ctx);
} else {
harvestIfPossible(context.getBlockPos().add(x, y, z), context.getWorld());
}
}
}
}
}
return res;
}
private void removePossibleGrass(World world, BlockPos pos) {
Block block = world.getBlockState(pos).getBlock();
Boolean grassFound = Blocks.FERN.equals(block) || Blocks.LARGE_FERN.equals(block)
|| Blocks.SHORT_GRASS.equals(block) || Blocks.TALL_GRASS.equals(block);
if (grassFound) {
world.breakBlock(pos, true);
}
}
private void harvestIfPossible(BlockPos pos, World world) {
BlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
if (block instanceof CropBlock) {
CropBlock cBlock = (CropBlock) block;
if (cBlock.isMature(blockState)) {
Block.dropStacks(blockState, world, pos);
world.setBlockState(pos, cBlock.withAge(0));
}
}
}
@Override
public HarvestRange getRange(ItemStack stack) {
// TODO: get range from stack
return range;
}
@Override
public boolean canBreakNeighbors(BlockState blockState) {
return super.isSuitableFor(blockState) || Blocks.TALL_GRASS.equals(blockState.getBlock())
|| Blocks.FERN.equals(blockState.getBlock()) || Blocks.LARGE_FERN.equals(blockState.getBlock());
}
@Override
public List<Block> getBlockList(Block block) {
return Lists.newArrayList(block);
}
}

View File

@ -1,104 +1,18 @@
package de.jottyfan.minecraft.quickiefabric.tools;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.CropBlock;
import net.minecraft.item.HoeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class ToolSpeedpowderHoe extends HoeItem implements ToolRangeable {
public class ToolSpeedpowderHoe extends ToolRangeableHoe {
public static final Integer DEFAULT_PLOW_RANGE = 4;
public HarvestRange range;
public static final Integer DEFAULT_PLOW_RANGE = 2;
public ToolSpeedpowderHoe() {
super(ToolMaterials.DIAMOND, 4, 2.0f, new FabricItemSettings());
this.range = new HarvestRange(DEFAULT_PLOW_RANGE);
super(ToolMaterials.DIAMOND, 4, 2.0f, new FabricItemSettings(), new HarvestRange(DEFAULT_PLOW_RANGE));
}
@Override
public ActionResult useOnBlock(ItemUsageContext context) {
ActionResult res = super.useOnBlock(context);
boolean isCrop = context.getWorld().getBlockState(context.getBlockPos()).getBlock() instanceof CropBlock;
if (!ActionResult.PASS.equals(res) || isCrop) {
for (int x = -this.range.getxRange(); x <= this.range.getxRange(); x++) {
for (int y = -this.range.getyRange(); y <= this.range.getyRange(); y++) {
for (int z = -this.range.getzRange(); z <= this.range.getzRange(); z++) {
if (!isCrop) {
BlockHitResult bhr = new BlockHitResult(context.getHitPos(), Direction.UP,
context.getBlockPos().add(new Vec3i(x, y, z)), isDamageable());
ItemUsageContext ctx = new ItemUsageContext(context.getPlayer(), context.getHand(), bhr);
super.useOnBlock(ctx);
} else {
harvestIfPossible(context.getBlockPos().add(x, y, z), context.getWorld());
}
}
}
}
}
return res;
}
private void harvestIfPossible(BlockPos pos, World world) {
BlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
if (block instanceof CropBlock) {
CropBlock cBlock = (CropBlock) block;
if (cBlock.isMature(blockState)) {
Block.dropStacks(blockState, world, pos);
world.setBlockState(pos, cBlock.withAge(0));
}
}
}
@Override
public HarvestRange getRange(ItemStack stack) {
// TODO: get range from stack
return range;
}
@Override
public boolean canBreakNeighbors(BlockState blockState) {
return super.isSuitableFor(blockState)
|| Blocks.TALL_GRASS.equals(blockState.getBlock())
|| Blocks.FERN.equals(blockState.getBlock())
|| Blocks.LARGE_FERN.equals(blockState.getBlock());
}
@Override
public List<Block> getBlockList(Block block) {
return Lists.newArrayList(block);
}
// @Override
// public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
// CommonToolCode.onItemRightClick(worldIn, playerIn, handIn);
// return super.onItemRightClick(worldIn, playerIn, handIn);
// }
//
// @Override
// public void addInformation(ItemStack stack, World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
// CommonToolCode.addInformation(stack, worldIn, tooltip, flagIn);
// super.addInformation(stack, worldIn, tooltip, flagIn);
// }
}

View File

@ -15,15 +15,6 @@ import net.minecraft.world.World;
*
*/
public class ToolSpeedpowderWaterHoe extends ToolSpeedpowderHoe {
public static final Integer DEFAULT_PLOW_RANGE = 4;
public HarvestRange range;
public ToolSpeedpowderWaterHoe() {
super();
this.range = new HarvestRange(DEFAULT_PLOW_RANGE);
}
@Override
public ActionResult useOnBlock(ItemUsageContext context) {
ActionResult res = super.useOnBlock(context);

View File

@ -10,6 +10,8 @@
"item.quickiefabric.quickiepowderaxe": "Eilpulveraxt",
"item.quickiefabric.quickiepowderpickaxe": "Eilpulverspitzhacke",
"item.quickiefabric.quickiepowdershovel": "Eilpulverschaufel",
"item.quickiefabric.quickiepowderhoe": "Eilpulverfeldhacke",
"item.quickiefabric.quickiepowderwaterhoe": "bewässerte Eilpulverfeldhacke",
"item.quickiefabric.sulphor": "Schwefel",
"item.quickiefabric.salpeter": "Salpeter",
"item.quickiefabric.construction0": "leerer Bauplan",

View File

@ -10,6 +10,8 @@
"item.quickiefabric.quickiepowderaxe": "hurrypowder axe",
"item.quickiefabric.quickiepowderpickaxe": "hurrypowder pickaxe",
"item.quickiefabric.quickiepowdershovel": "hurrypowder shovel",
"item.quickiefabric.quickiepowderhoe": "hurrypowder hoe",
"item.quickiefabric.quickiepowderwaterhoe": "watered hurrypowder hoe",
"item.quickiefabric.sulphor": "sulfur",
"item.quickiefabric.salpeter": "salpeter",
"item.quickiefabric.construction0": "empty building plan",

View File

@ -0,0 +1,6 @@
{
"parent": "item/wooden_hoe",
"textures": {
"layer0": "quickiefabric:item/quickiepowderhoe"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/wooden_hoe",
"textures": {
"layer0": "quickiefabric:item/quickiepowderwaterhoe"
}
}

View File

@ -2,6 +2,8 @@
"replace": false,
"values": [
"quickiefabric:speedpowderhoe",
"quickiefabric:speedpowderwaterhoe"
"quickiefabric:speedpowderwaterhoe",
"quickiefabric:quickiepowderhoe",
"quickiefabric:quickiepowderwaterhoe"
]
}

View File

@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"ss",
" |",
" |"
],
"key": {
"s": {
"item": "quickiefabric:quickiepowder"
},
"|": {
"item": "minecraft:stick"
}
},
"result": {
"item": "quickiefabric:quickiepowderhoe",
"count": 1
}
}

View File

@ -0,0 +1,15 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "minecraft:water_bucket"
},
{
"item": "quickiefabric:quickiepowderhoe"
}
],
"result": {
"item": "quickiefabric:quickiepowderwaterhoe",
"count": 1
}
}