normalized tools
This commit is contained in:
@@ -83,28 +83,28 @@ public class EventBlockBreak {
|
||||
if (tool instanceof Item) {
|
||||
Item toolItem = (Item) tool; // a rangeable tool should always be an item
|
||||
List<String> visitedBlocks = new ArrayList<>();
|
||||
if (QuicklyItems.TOOL_SPEEDPOWDERAXE.getName().equals(toolItem.getName())) {
|
||||
if (QuicklyItems.SPEEDAXE.getName().equals(toolItem.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS,
|
||||
player, true);
|
||||
} else if (QuicklyItems.TOOL_SPEEDPOWDERPICKAXE.getName().equals(toolItem.getName())) {
|
||||
} else if (QuicklyItems.SPEEDPICKAXE.getName().equals(toolItem.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
player, false);
|
||||
} else if (QuicklyItems.TOOL_SPEEDPOWDERSHOVEL.getName().equals(toolItem.getName())) {
|
||||
} else if (QuicklyItems.SPEEDSHOVEL.getName().equals(toolItem.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
player, false);
|
||||
} else if (QuicklyItems.TOOL_SPEEDPOWDERHOE.getName().equals(toolItem.getName())) {
|
||||
} else if (QuicklyItems.SPEEDHOE.getName().equals(toolItem.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
player, false);
|
||||
} else if (QuicklyItems.TOOL_QUICKIEPOWDERAXE.getName().equals(toolItem.getName())) {
|
||||
} else if (QuicklyItems.QUICKIEAXE.getName().equals(toolItem.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS,
|
||||
player, true);
|
||||
} else if (QuicklyItems.TOOL_QUICKIEPOWDERPICKAXE.getName().equals(toolItem.getName())) {
|
||||
} else if (QuicklyItems.QUICKIEPICKAXE.getName().equals(toolItem.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
player, false);
|
||||
} else if (QuicklyItems.TOOL_QUICKIEPOWDERSHOVEL.getName().equals(toolItem.getName())) {
|
||||
} else if (QuicklyItems.QUICKIESHOVEL.getName().equals(toolItem.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
player, false);
|
||||
} else if (QuicklyItems.TOOL_QUICKIEPOWDERHOE.getName().equals(toolItem.getName())) {
|
||||
} else if (QuicklyItems.QUICKIEHOE.getName().equals(toolItem.getName())) {
|
||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
||||
player, false);
|
||||
} else {
|
||||
|
||||
@@ -20,9 +20,9 @@ public class Plant extends Item {
|
||||
|
||||
private String plantName;
|
||||
|
||||
public Plant(Properties properties, String plantName) {
|
||||
public Plant(QP properties) {
|
||||
super(properties);
|
||||
this.plantName = plantName;
|
||||
this.plantName = properties.getBlockName();
|
||||
}
|
||||
|
||||
private Block getPlant() {
|
||||
|
||||
@@ -19,13 +19,13 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ToolRangeableAxe extends AxeItem implements ToolRangeable {
|
||||
public class QAxe extends AxeItem implements ToolRangeable {
|
||||
|
||||
private final HarvestRange range;
|
||||
|
||||
public ToolRangeableAxe(int duration, float attackDamage, float attackSpeed, Properties properties, HarvestRange range) {
|
||||
super(new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, duration, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS), attackDamage, attackSpeed, properties);
|
||||
this.range = range;
|
||||
public QAxe(QP properties) {
|
||||
super(new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, properties.getDurability(), 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS), 7f, 3.1f, properties);
|
||||
this.range = properties.getHarvestRange();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -6,6 +6,8 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.HoeItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -23,13 +25,13 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public abstract class ToolRangeableHoe extends HoeItem implements ToolRangeable {
|
||||
public class QHoe extends HoeItem implements ToolRangeable {
|
||||
|
||||
public HarvestRange range;
|
||||
public QP properties;
|
||||
|
||||
public ToolRangeableHoe(ToolMaterial material, float attackDamage, float attackSpeed, Properties properties, HarvestRange range) {
|
||||
super(material, attackDamage, attackSpeed, properties);
|
||||
this.range = range;
|
||||
public QHoe(QP properties) {
|
||||
super(new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, properties.getDurability(), 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS), 7f, 3.1f, properties);
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,9 +39,10 @@ public abstract class ToolRangeableHoe extends HoeItem implements ToolRangeable
|
||||
InteractionResult res = super.useOn(context);
|
||||
boolean isCrop = context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof CropBlock;
|
||||
if (!InteractionResult.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++) {
|
||||
HarvestRange range = properties.getHarvestRange();
|
||||
for (int x = -range.getxRange(); x <= range.getxRange(); x++) {
|
||||
for (int y = -range.getyRange(); y <= range.getyRange(); y++) {
|
||||
for (int z = -range.getzRange(); z <= range.getzRange(); z++) {
|
||||
if (!isCrop) {
|
||||
removePossibleGrass(context.getLevel(), new BlockPos(x, y, z));
|
||||
BlockHitResult bhr = new BlockHitResult(context.getClickedPos().getCenter(), Direction.UP,
|
||||
@@ -77,12 +80,6 @@ public abstract class ToolRangeableHoe extends HoeItem implements ToolRangeable
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HarvestRange getRange(ItemStack stack) {
|
||||
// TODO: get range from stack
|
||||
return range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreakNeighbors(BlockState blockState) {
|
||||
return new ItemStack(this).isCorrectToolForDrops(blockState) || Blocks.TALL_GRASS.equals(blockState.getBlock())
|
||||
@@ -93,4 +90,9 @@ public abstract class ToolRangeableHoe extends HoeItem implements ToolRangeable
|
||||
public List<Block> getBlockList(Block block) {
|
||||
return Lists.newArrayList(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HarvestRange getRange(ItemStack stack) {
|
||||
return properties.getHarvestRange();
|
||||
}
|
||||
}
|
||||
137
src/main/java/de/jottyfan/minecraft/item/QP.java
Normal file
137
src/main/java/de/jottyfan/minecraft/item/QP.java
Normal file
@@ -0,0 +1,137 @@
|
||||
package de.jottyfan.minecraft.item;
|
||||
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.equipment.ArmorMaterial;
|
||||
import net.minecraft.world.item.equipment.ArmorType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class QP extends Item.Properties {
|
||||
private Item fallbackItem;
|
||||
private HarvestRange harvestRange;
|
||||
private Integer durability;
|
||||
private Integer minDrops;
|
||||
private String blockName;
|
||||
|
||||
public static final QP of(Integer xRange, Integer yRange, Integer zRange, Integer durability) {
|
||||
QP properties = new QP();
|
||||
properties.setHarvestRange(new HarvestRange(xRange, yRange, zRange));
|
||||
properties.setDurability(durability);
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static final QP of(Item fallbackItem, Integer harvestRange, Integer durability) {
|
||||
QP properties = new QP();
|
||||
properties.setFallbackItem(fallbackItem);
|
||||
properties.setHarvestRange(new HarvestRange(harvestRange));
|
||||
properties.setDurability(durability);
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static final QP of(Integer harvestRange, Integer durability) {
|
||||
QP properties = new QP();
|
||||
properties.setHarvestRange(new HarvestRange(harvestRange));
|
||||
properties.setDurability(durability);
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static QP of(Integer minDrops) {
|
||||
QP properties = new QP();
|
||||
properties.setMinDrops(minDrops);
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static QP of(String blockName) {
|
||||
QP properties = new QP();
|
||||
properties.setBlockName(blockName);
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QP humanoidArmor(ArmorMaterial material, ArmorType type) {
|
||||
super.humanoidArmor(material, type);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QP stacksTo(int max) {
|
||||
super.stacksTo(max);
|
||||
return this;
|
||||
}
|
||||
|
||||
public final QP setVanilla(ResourceKey<Item> id, Identifier modelId) {
|
||||
super.setId(id);
|
||||
super.modelId(modelId);
|
||||
super.useItemDescriptionPrefix();
|
||||
return this;
|
||||
}
|
||||
|
||||
private void setFallbackItem(Item fallbackItem) {
|
||||
this.fallbackItem = fallbackItem;
|
||||
}
|
||||
|
||||
public Item getFallbackItem() {
|
||||
return fallbackItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the harvestRange
|
||||
*/
|
||||
public HarvestRange getHarvestRange() {
|
||||
return harvestRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param harvestRange the harvestRange to set
|
||||
*/
|
||||
public void setHarvestRange(HarvestRange harvestRange) {
|
||||
this.harvestRange = harvestRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the durability
|
||||
*/
|
||||
public Integer getDurability() {
|
||||
return durability;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param durability the durability to set
|
||||
*/
|
||||
public void setDurability(Integer durability) {
|
||||
this.durability = durability;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minDrops
|
||||
*/
|
||||
public Integer getMinDrops() {
|
||||
return minDrops;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param minDrops the minDrops to set
|
||||
*/
|
||||
public void setMinDrops(Integer minDrops) {
|
||||
this.minDrops = minDrops;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the blockName
|
||||
*/
|
||||
public String getBlockName() {
|
||||
return blockName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param blockName the blockName to set
|
||||
*/
|
||||
public void setBlockName(String blockName) {
|
||||
this.blockName = blockName;
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,12 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ToolRangeablePickaxe extends Item implements ToolRangeable {
|
||||
public class QPickaxe extends Item implements ToolRangeable {
|
||||
private HarvestRange range;
|
||||
|
||||
public ToolRangeablePickaxe(Properties properties, Integer duration, HarvestRange range) {
|
||||
super(properties.pickaxe(new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, duration, 7.0F, 1.0F, 15, ItemTags.DIAMOND_TOOL_MATERIALS), 7F, -3.1F));
|
||||
this.range = range;
|
||||
public QPickaxe(QP properties) {
|
||||
super(properties.pickaxe(new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, properties.getDurability(), 7.0F, 1.0F, 15, ItemTags.DIAMOND_TOOL_MATERIALS), 7F, -3.1F));
|
||||
this.range = properties.getHarvestRange();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,7 +1,5 @@
|
||||
package de.jottyfan.minecraft.item;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -19,23 +17,24 @@ import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.ShearsItem;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ToolQuickiepowderShears extends ShearsItem {
|
||||
public class QShears extends ShearsItem {
|
||||
private final Integer minimum;
|
||||
|
||||
public ToolQuickiepowderShears(Properties properties) {
|
||||
public QShears(QP properties) {
|
||||
super(properties.component(DataComponents.TOOL, ShearsItem.createToolProperties()));
|
||||
this.minimum = properties.getMinDrops();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult interactLivingEntity(ItemStack stack, Player user, LivingEntity entity,
|
||||
InteractionHand hand) {
|
||||
Vec3 pos = entity.position();
|
||||
Integer amount = 3 + new Random().nextInt(4);
|
||||
Integer amount = minimum + entity.getRandom().nextInt(4);
|
||||
if (entity instanceof Sheep sheep) {
|
||||
if (!sheep.isSheared()) {
|
||||
sheep.setSheared(true);
|
||||
@@ -18,12 +18,12 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class ToolRangeableShovel extends ShovelItem implements ToolRangeable {
|
||||
public class QShovel extends ShovelItem implements ToolRangeable {
|
||||
public HarvestRange range;
|
||||
|
||||
public ToolRangeableShovel(Properties properties, Integer durability, HarvestRange range) {
|
||||
super(new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, durability, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS), 7F, -3.1F, properties);
|
||||
this.range = range;
|
||||
public QShovel(QP properties) {
|
||||
super(new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, properties.getDurability(), 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS), 7F, -3.1F, properties);
|
||||
this.range = properties.getHarvestRange();
|
||||
}
|
||||
|
||||
private void createPathOnGrass(Level level, BlockPos pos, Direction side) {
|
||||
34
src/main/java/de/jottyfan/minecraft/item/QWaterHoe.java
Normal file
34
src/main/java/de/jottyfan/minecraft/item/QWaterHoe.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package de.jottyfan.minecraft.item;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class QWaterHoe extends QHoe {
|
||||
private QP properties;
|
||||
|
||||
public QWaterHoe(QP properties) {
|
||||
super(properties);
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
InteractionResult res = super.useOn(context);
|
||||
if (!InteractionResult.PASS.equals(res)) {
|
||||
BlockPos pos = context.getClickedPos();
|
||||
Level level = context.getLevel();
|
||||
level.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());
|
||||
context.getPlayer().setItemInHand(context.getHand(), new ItemStack(properties.getFallbackItem()));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Item.Properties;
|
||||
import net.minecraft.world.item.equipment.ArmorType;
|
||||
|
||||
/**
|
||||
@@ -20,17 +19,15 @@ import net.minecraft.world.item.equipment.ArmorType;
|
||||
*
|
||||
*/
|
||||
public class QuicklyItems {
|
||||
public static final Item STUB = registerItem("stub", properties -> new Stub(properties));
|
||||
public static final Item STUB = registerItem("stub", Stub::new);
|
||||
public static final Item RAWTURQUOISE = registerItem("rawturquoise");
|
||||
public static final Item TURQUOISEINGOT = registerItem("turquoiseingot");
|
||||
public static final Item COTTON = registerItem("cotton");
|
||||
public static final Item COTTONPLANT = registerItem("cottonplant");
|
||||
public static final Item COTTONSEED = registerItem("cottonseed",
|
||||
properties -> new Plant(properties, "blockcottonplant"));
|
||||
public static final Item COTTONSEED = registerItem("cottonseed", QP.of("blockcottonplant"), Plant::new);
|
||||
public static final Item CANOLA = registerItem("canola");
|
||||
public static final Item CANOLAPLANT = registerItem("canolaplant");
|
||||
public static final Item CANOLASEED = registerItem("canolaseed",
|
||||
properties -> new Plant(properties, "blockcanolaplant"));
|
||||
public static final Item CANOLASEED = registerItem("canolaseed", QP.of("blockcanolaplant"), Plant::new);
|
||||
public static final Item CANOLABOTTLE = registerItem("canolabottle");
|
||||
public static final Item CANOLABOTTLESTACK = registerItem("canolabottlestack");
|
||||
public static final Item ROTTENFLESHSTRIPES = registerItem("rotten_flesh_stripes");
|
||||
@@ -48,34 +45,31 @@ public class QuicklyItems {
|
||||
public static final Item SULFOR = registerItem("sulfor");
|
||||
public static final Item CARROTSTACK = registerItem("carrotstack");
|
||||
|
||||
// TODO: normalize classes and try to summarize tools (such as ToolShovel for both speed and quickie)
|
||||
// TODO: rename tools to speedaxe and quickaxe instead of the powder version
|
||||
|
||||
public static final Item TOOL_SPEEDPOWDERAXE = registerItem("speedpowderaxe",
|
||||
properties -> new ToolRangeableAxe(800, 7f, -3.1f, properties, new HarvestRange(32, 64, 32)));
|
||||
public static final Item TOOL_SPEEDPOWDERHOE = registerItem("speedpowderhoe",
|
||||
properties -> new ToolSpeedpowderHoe(properties));
|
||||
public static final Item TOOL_SPEEDPOWDERPICKAXE = registerItem("speedpowderpickaxe",
|
||||
properties -> new ToolRangeablePickaxe(properties, 800, new HarvestRange(3)));
|
||||
public static final Item TOOL_SPEEDPOWDERSHEARS = registerItem("speedpowdershears",
|
||||
properties -> new ToolSpeedpowderShears(properties));
|
||||
public static final Item TOOL_SPEEDPOWDERSHOVEL = registerItem("speedpowdershovel",
|
||||
properties -> new ToolRangeableShovel(properties, 800, new HarvestRange(3)));
|
||||
public static final Item TOOL_SPEEDPOWDERWATERHOE = registerItem("speedpowderwaterhoe",
|
||||
properties -> new ToolSpeedpowderWaterHoe(properties, QuicklyItems.TOOL_SPEEDPOWDERHOE));
|
||||
public static final Item TOOL_QUICKIEPOWDERAXE = registerItem("quickiepowderaxe",
|
||||
properties -> new ToolRangeableAxe(2400, 7F, -3.1F, properties, new HarvestRange(64, 128, 64)));
|
||||
public static final Item TOOL_QUICKIEPOWDERHOE = registerItem("quickiepowderhoe",
|
||||
properties -> new ToolQuickiepowderHoe(properties));
|
||||
public static final Item TOOL_QUICKIEPOWDERPICKAXE = registerItem("quickiepowderpickaxe",
|
||||
properties -> new ToolRangeablePickaxe(properties, 2400, new HarvestRange(6)));
|
||||
public static final Item TOOL_QUICKIEPOWDERSHOVEL = registerItem("quickiepowdershovel",
|
||||
properties -> new ToolRangeableShovel(properties, 2400, new HarvestRange(6)));
|
||||
public static final Item TOOL_QUICKIEPOWDERWATERHOE = registerItem("quickiepowderwaterhoe",
|
||||
properties -> new ToolQuickiepowderWaterHoe(properties, QuicklyItems.TOOL_QUICKIEPOWDERHOE));
|
||||
public static final Item TOOL_QUICKIEPOWDERSHEARS = registerItem("quickiepowdershears",
|
||||
properties -> new ToolSpeedpowderShears(properties));
|
||||
// tools
|
||||
private static final Integer SPEED_DURATION = 800;
|
||||
private static final Integer QUICKIE_DURATION = 2400;
|
||||
|
||||
public static final Item SPEEDAXE = registerItem("speedpowderaxe", QP.of(32, 64, 32, SPEED_DURATION), QAxe::new);
|
||||
public static final Item SPEEDHOE = registerItem("speedpowderhoe", QP.of(2, SPEED_DURATION), QHoe::new);
|
||||
public static final Item SPEEDPICKAXE = registerItem("speedpowderpickaxe", QP.of(3, SPEED_DURATION), QPickaxe::new);
|
||||
public static final Item SPEEDSHEARS = registerItem("speedpowdershears", QP.of(1), QShears::new);
|
||||
public static final Item SPEEDSHOVEL = registerItem("speedpowdershovel", QP.of(3, SPEED_DURATION), QShovel::new);
|
||||
public static final Item SPEEDWATERHOE = registerItem("speedpowderwaterhoe", QP.of(SPEEDHOE, 2, SPEED_DURATION),
|
||||
QWaterHoe::new);
|
||||
public static final Item QUICKIEAXE = registerItem("quickiepowderaxe", QP.of(64, 128, 64, QUICKIE_DURATION),
|
||||
QAxe::new);
|
||||
public static final Item QUICKIEHOE = registerItem("quickiepowderhoe", QP.of(4, QUICKIE_DURATION), QHoe::new);
|
||||
public static final Item QUICKIEPICKAXE = registerItem("quickiepowderpickaxe", QP.of(6, QUICKIE_DURATION),
|
||||
QPickaxe::new);
|
||||
public static final Item QUICKIESHEARS = registerItem("quickiepowdershears", QP.of(3), QShears::new);
|
||||
public static final Item QUICKIESHOVEL = registerItem("quickiepowdershovel", QP.of(6, QUICKIE_DURATION),
|
||||
QShovel::new);
|
||||
public static final Item QUICKIEWATERHOE = registerItem("quickiepowderwaterhoe",
|
||||
QP.of(QUICKIEHOE, 4, QUICKIE_DURATION), QWaterHoe::new);
|
||||
|
||||
// armor
|
||||
public static final Item ARMOR_TURQUOISE_BOOTS = registerItem("turquoise_boots", ArmorType.BOOTS);
|
||||
public static final Item ARMOR_TURQUOISE_HELMET = registerItem("turquoise_helmet", ArmorType.HELMET);
|
||||
public static final Item ARMOR_TURQUOISE_LEGGINGS = registerItem("turquoise_leggings", ArmorType.LEGGINGS);
|
||||
@@ -83,25 +77,24 @@ public class QuicklyItems {
|
||||
|
||||
private static final Item registerItem(String name, ArmorType armorType) {
|
||||
return QuicklyItems.registerItem(name,
|
||||
new Item.Properties().stacksTo(1).humanoidArmor(ModArmorMaterials.TURQUOISE_ARMOR_MATERIAL, armorType));
|
||||
new QP().stacksTo(1).humanoidArmor(ModArmorMaterials.TURQUOISE_ARMOR_MATERIAL, armorType));
|
||||
}
|
||||
|
||||
private static final Item registerItem(String name) {
|
||||
return QuicklyItems.registerItem(name, new Item.Properties());
|
||||
return QuicklyItems.registerItem(name, new QP());
|
||||
}
|
||||
|
||||
private static final Item registerItem(String name, Item.Properties properties) {
|
||||
return QuicklyItems.registerItem(name, properties, p -> new Item(p));
|
||||
private static final Item registerItem(String name, QP properties) {
|
||||
return QuicklyItems.registerItem(name, properties, Item::new);
|
||||
}
|
||||
|
||||
private static final Item registerItem(String name, Function<Properties, Item> function) {
|
||||
return QuicklyItems.registerItem(name, new Item.Properties(), function);
|
||||
private static final Item registerItem(String name, Function<QP, Item> function) {
|
||||
return QuicklyItems.registerItem(name, new QP(), function);
|
||||
}
|
||||
|
||||
private static final Item registerItem(String name, Item.Properties properties, Function<Properties, Item> function) {
|
||||
private static final Item registerItem(String name, QP properties, Function<QP, Item> function) {
|
||||
Identifier identifier = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, name);
|
||||
Item item = function.apply(properties.setId(ResourceKey.create(Registries.ITEM, identifier)).modelId(identifier)
|
||||
.useItemDescriptionPrefix());
|
||||
Item item = function.apply(properties.setVanilla(ResourceKey.create(Registries.ITEM, identifier), identifier));
|
||||
return Registry.register(BuiltInRegistries.ITEM, identifier, item);
|
||||
}
|
||||
|
||||
@@ -134,18 +127,18 @@ public class QuicklyItems {
|
||||
item.accept(ARMOR_TURQUOISE_CHESTPLATE);
|
||||
item.accept(ARMOR_TURQUOISE_LEGGINGS);
|
||||
item.accept(ARMOR_TURQUOISE_BOOTS);
|
||||
item.accept(TOOL_QUICKIEPOWDERPICKAXE);
|
||||
item.accept(TOOL_QUICKIEPOWDERAXE);
|
||||
item.accept(TOOL_QUICKIEPOWDERSHOVEL);
|
||||
item.accept(TOOL_QUICKIEPOWDERSHEARS);
|
||||
item.accept(TOOL_QUICKIEPOWDERHOE);
|
||||
item.accept(TOOL_QUICKIEPOWDERWATERHOE);
|
||||
item.accept(TOOL_SPEEDPOWDERPICKAXE);
|
||||
item.accept(TOOL_SPEEDPOWDERAXE);
|
||||
item.accept(TOOL_SPEEDPOWDERSHOVEL);
|
||||
item.accept(TOOL_SPEEDPOWDERSHEARS);
|
||||
item.accept(TOOL_SPEEDPOWDERHOE);
|
||||
item.accept(TOOL_SPEEDPOWDERWATERHOE);
|
||||
item.accept(QUICKIEPICKAXE);
|
||||
item.accept(QUICKIEAXE);
|
||||
item.accept(QUICKIESHOVEL);
|
||||
item.accept(QUICKIESHEARS);
|
||||
item.accept(QUICKIEHOE);
|
||||
item.accept(QUICKIEWATERHOE);
|
||||
item.accept(SPEEDPICKAXE);
|
||||
item.accept(SPEEDAXE);
|
||||
item.accept(SPEEDSHOVEL);
|
||||
item.accept(SPEEDSHEARS);
|
||||
item.accept(SPEEDHOE);
|
||||
item.accept(SPEEDWATERHOE);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package de.jottyfan.minecraft.item;
|
||||
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.item.ToolMaterial;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ToolQuickiepowderHoe extends ToolRangeableHoe {
|
||||
|
||||
public static final Integer DEFAULT_PLOW_RANGE = 4;
|
||||
private final static ToolMaterial MATERIAL = new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 2400, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS);
|
||||
|
||||
public ToolQuickiepowderHoe(Properties properties) {
|
||||
super(MATERIAL, 7F, -3.1f, properties, new HarvestRange(DEFAULT_PLOW_RANGE));
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package de.jottyfan.minecraft.item;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ToolQuickiepowderWaterHoe extends ToolQuickiepowderHoe {
|
||||
private Item fallbackHoe;
|
||||
|
||||
public ToolQuickiepowderWaterHoe(Properties properties, Item fallbackHoe) {
|
||||
super(properties);
|
||||
this.fallbackHoe = fallbackHoe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
InteractionResult res = super.useOn(context);
|
||||
if (!InteractionResult.PASS.equals(res)) {
|
||||
BlockPos pos = context.getClickedPos();
|
||||
Level level = context.getLevel();
|
||||
BlockState oldBlockState = level.getBlockState(pos);
|
||||
level.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());
|
||||
InteractionHand hand = context.getHand();
|
||||
Player player = context.getPlayer();
|
||||
ItemStack oldTool = player.getItemInHand(hand);
|
||||
ItemStack newTool = new ItemStack(fallbackHoe);
|
||||
newTool.setDamageValue(oldTool.getDamageValue());
|
||||
level.addFreshEntity(
|
||||
new ItemEntity(level, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(oldBlockState.getBlock())));
|
||||
player.setItemInHand(hand, newTool);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package de.jottyfan.minecraft.item;
|
||||
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.item.ToolMaterial;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ToolSpeedpowderHoe extends ToolRangeableHoe {
|
||||
|
||||
public static final Integer DEFAULT_PLOW_RANGE = 2;
|
||||
private final static ToolMaterial MATERIAL = new ToolMaterial(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 800, 7f, 1f, 15, ItemTags.DIAMOND_TOOL_MATERIALS);
|
||||
|
||||
public ToolSpeedpowderHoe(Properties properties) {
|
||||
super(MATERIAL, 7F, -3.1F, properties, new HarvestRange(DEFAULT_PLOW_RANGE));
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package de.jottyfan.minecraft.item;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.animal.chicken.Chicken;
|
||||
import net.minecraft.world.entity.animal.cow.Cow;
|
||||
import net.minecraft.world.entity.animal.equine.Horse;
|
||||
import net.minecraft.world.entity.animal.sheep.Sheep;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.ShearsItem;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ToolSpeedpowderShears extends ShearsItem {
|
||||
|
||||
public ToolSpeedpowderShears(Properties properties) {
|
||||
super(properties.component(DataComponents.TOOL, ShearsItem.createToolProperties()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
return super.useOn(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult interactLivingEntity(ItemStack stack, Player user, LivingEntity entity,
|
||||
InteractionHand hand) {
|
||||
Vec3 pos = entity.position();
|
||||
Integer amount = 1 + new Random().nextInt(4);
|
||||
if (entity instanceof Sheep sheep) {
|
||||
if (!sheep.isSheared()) {
|
||||
sheep.setSheared(true);
|
||||
sheep.playAmbientSound();
|
||||
DyeColor color = sheep.getColor();
|
||||
Item item = Items.WHITE_WOOL;
|
||||
if (color.equals(DyeColor.BLACK)) {
|
||||
item = Items.BLACK_WOOL;
|
||||
} else if (color.equals(DyeColor.GRAY)) {
|
||||
item = Items.GRAY_WOOL;
|
||||
} else if (color.equals(DyeColor.LIGHT_GRAY)) {
|
||||
item = Items.LIGHT_GRAY_WOOL;
|
||||
} else if (color.equals(DyeColor.BROWN)) {
|
||||
item = Items.BROWN_WOOL;
|
||||
} else if (color.equals(DyeColor.BLUE)) {
|
||||
item = Items.BLUE_WOOL;
|
||||
} else if (color.equals(DyeColor.LIGHT_BLUE)) {
|
||||
item = Items.LIGHT_BLUE_WOOL;
|
||||
} else if (color.equals(DyeColor.GREEN)) {
|
||||
item = Items.GREEN_WOOL;
|
||||
} else if (color.equals(DyeColor.LIME)) {
|
||||
item = Items.LIME_WOOL;
|
||||
} else if (color.equals(DyeColor.CYAN)) {
|
||||
item = Items.CYAN_WOOL;
|
||||
} else if (color.equals(DyeColor.MAGENTA)) {
|
||||
item = Items.MAGENTA_WOOL;
|
||||
} else if (color.equals(DyeColor.ORANGE)) {
|
||||
item = Items.ORANGE_WOOL;
|
||||
} else if (color.equals(DyeColor.PINK)) {
|
||||
item = Items.PINK_WOOL;
|
||||
} else if (color.equals(DyeColor.PURPLE)) {
|
||||
item = Items.PURPLE_WOOL;
|
||||
} else if (color.equals(DyeColor.RED)) {
|
||||
item = Items.RED_WOOL;
|
||||
} else if (color.equals(DyeColor.YELLOW)) {
|
||||
item = Items.YELLOW_WOOL;
|
||||
}
|
||||
user.level().addFreshEntity(new ItemEntity(user.level(), pos.x, pos.y, pos.z, new ItemStack(item, amount)));
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
} else if (entity instanceof Horse horse) {
|
||||
horse.playAmbientSound();
|
||||
horse.setBaby(true);
|
||||
user.level()
|
||||
.addFreshEntity(new ItemEntity(user.level(), pos.x, pos.y, pos.z, new ItemStack(Items.LEATHER, amount)));
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (entity instanceof Cow cow) {
|
||||
cow.playAmbientSound();
|
||||
cow.setBaby(true);
|
||||
user.level()
|
||||
.addFreshEntity(new ItemEntity(user.level(), pos.x, pos.y, pos.z, new ItemStack(Items.LEATHER, amount)));
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (entity instanceof Chicken chicken) {
|
||||
chicken.playAmbientSound();
|
||||
chicken.setBaby(true);
|
||||
user.level()
|
||||
.addFreshEntity(new ItemEntity(user.level(), pos.x, pos.y, pos.z, new ItemStack(Items.FEATHER, amount)));
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package de.jottyfan.minecraft.item;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class ToolSpeedpowderWaterHoe extends ToolSpeedpowderHoe {
|
||||
private Item fallbackHoe;
|
||||
|
||||
public ToolSpeedpowderWaterHoe(Properties properties, Item fallbackHoe) {
|
||||
super(properties);
|
||||
this.fallbackHoe = fallbackHoe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
InteractionResult res = super.useOn(context);
|
||||
if (!InteractionResult.PASS.equals(res)) {
|
||||
BlockPos pos = context.getClickedPos();
|
||||
Level level = context.getLevel();
|
||||
BlockState oldBlockState = level.getBlockState(pos);
|
||||
level.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());
|
||||
InteractionHand hand = context.getHand();
|
||||
Player player = context.getPlayer();
|
||||
ItemStack oldTool = player.getItemInHand(hand);
|
||||
ItemStack newTool = new ItemStack(fallbackHoe);
|
||||
newTool.setDamageValue(oldTool.getDamageValue());
|
||||
level.addFreshEntity(
|
||||
new ItemEntity(level, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(oldBlockState.getBlock())));
|
||||
player.setItemInHand(hand, newTool);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user