added speedpowder hoe
This commit is contained in:
parent
f1949e811b
commit
3ae69a775f
0
logs/latest.log
Normal file
0
logs/latest.log
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
package de.jottyfan.minecraft.quickiefabric.tools;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import de.jottyfan.minecraft.quickiefabric.init.RegistryManager;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.item.HoeItem;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ItemUsageContext;
|
||||||
|
import net.minecraft.item.ToolMaterials;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.util.math.Vec3i;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jotty
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ToolSpeedpowderHoe extends HoeItem implements ToolRangeable {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(ToolSpeedpowderHoe.class);
|
||||||
|
public static final Integer DEFAULT_PLOW_RANGE = 4;
|
||||||
|
public HarvestRange range;
|
||||||
|
|
||||||
|
public ToolSpeedpowderHoe() {
|
||||||
|
super(ToolMaterials.DIAMOND, 4, 2.0f, new Item.Settings().group(RegistryManager.QUICKIEFABRIC_GROUP));
|
||||||
|
this.range = new HarvestRange(DEFAULT_PLOW_RANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResult useOnBlock(ItemUsageContext context) {
|
||||||
|
ActionResult res = super.useOnBlock(context);
|
||||||
|
if (!ActionResult.PASS.equals(res)) {
|
||||||
|
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++) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HarvestRange getRange(ItemStack stack) {
|
||||||
|
// TODO: get range from stack
|
||||||
|
return range;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBreakNeighbors(BlockState blockState) {
|
||||||
|
boolean result = HOE_EFFECTIVE_ON.contains(blockState.getBlock()) || checkExternalBlock(blockState.getBlock());
|
||||||
|
if (!result) {
|
||||||
|
if (!blockState.isAir()) {
|
||||||
|
LOGGER.debug("cannot break block {} with that speedpowder hoe", Registry.BLOCK.getId(blockState.getBlock()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkExternalBlock(Block block) {
|
||||||
|
boolean result = false;
|
||||||
|
for (Identifier externalID : HOE_EXTERNAL_EFFECTIVE_ON) {
|
||||||
|
Block registeredBlock = Registry.BLOCK.get(externalID); // may be null if mods are not available
|
||||||
|
result = result || (registeredBlock != null && registeredBlock.equals(block));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
// }
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "item/wooden_hoe",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "quickiefabric:item/speedpowderhoe"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"ss",
|
||||||
|
" |",
|
||||||
|
" |"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"s": {
|
||||||
|
"item": "quickiefabric:speedpowder"
|
||||||
|
},
|
||||||
|
"|": {
|
||||||
|
"item": "minecraft:stick"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "quickiefabric:speedpowderhoe",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user