code cleanup

This commit is contained in:
Jottyfan
2026-01-11 23:13:39 +01:00
parent 0809dca67f
commit ec309be497
11 changed files with 63 additions and 59 deletions

View File

@@ -24,6 +24,11 @@ public class BlockOre extends Block {
private SoundEvent soundEvent;
private ItemStack[] dropItems;
public BlockOre(Properties properties, ItemStack... dropItems) {
super(properties.requiresCorrectToolForDrops());
this.dropItems = dropItems;
}
public BlockOre(Properties properties, SoundEvent soundEvent, ItemStack... dropItems) {
super(properties.requiresCorrectToolForDrops());
this.soundEvent = soundEvent;

View File

@@ -39,41 +39,40 @@ public class QuicklyBlocks {
public static final Block CANOLAPLANT = registerBlock("blockcanolaplant", Properties.ofFullCopy(Blocks.WHEAT),
properties -> new BlockPlant(properties, "canolaseed", "canola"));
public static final Block LAVAHOARDER = registerBlock("lavahoarder",
Properties.of().strength(2.5f).lightLevel(state -> state.getValue(Lavahoarder.FILLED) ? 15 : 0), properties -> new Lavahoarder(properties));
Properties.of().strength(2.5f).lightLevel(state -> state.getValue(Lavahoarder.FILLED) ? 15 : 0), Lavahoarder::new);
public static final Block QUICKIEPOWDER = registerBlock("blockquickiepowder",
properties -> new BlockDrops(properties, new ItemStack(QuicklyItems.QUICKIEPOWDER, 9)));
public static final Block SPEEDPOWDER = registerBlock("blockspeedpowder",
properties -> new BlockDrops(properties, new ItemStack(QuicklyItems.SPEEDPOWDER, 9)));
public static final Block MONSTERHOARDER = registerBlock("monsterhoarder",
properties -> new Monsterhoarder(properties));
public static final Block ITEMHOARDER = registerBlock("itemhoarder", properties -> new Itemhoarder(properties));
public static final Block DRILL = registerBlock("drill", properties -> new BlockDrill(properties));
public static final Block MONSTERHOARDER = registerBlock("monsterhoarder", Monsterhoarder::new);
public static final Block ITEMHOARDER = registerBlock("itemhoarder", Itemhoarder::new);
public static final Block DRILL = registerBlock("drill", BlockDrill::new);
public static final Block STACKER = registerBlock("blockstacker",
properties -> new BlockStacker(properties.strength(2.5f)));
public static final Block DIRTSALPETER = registerBlock("dirtsalpeter",
properties -> new BlockOre(properties.strength(2.2f), null, new ItemStack(QuicklyItems.SALPETER, 1),
properties -> new BlockOre(properties.strength(2.2f), new ItemStack(QuicklyItems.SALPETER, 1),
new ItemStack(Items.DIRT)));
public static final Block SANDSALPETER = registerBlock("sandsalpeter",
properties -> new BlockOre(properties.strength(1.5f), null, new ItemStack(QuicklyItems.SALPETER, 2),
properties -> new BlockOre(properties.strength(1.5f), new ItemStack(QuicklyItems.SALPETER, 2),
new ItemStack(Items.SAND)));
public static final Block OREDEEPSLATESULFOR = registerBlock("oredeepslatesulfor",
properties -> new BlockOre(properties.strength(2.0f), null, new ItemStack(QuicklyItems.SULFOR, 4)));
properties -> new BlockOre(properties.strength(2.0f), new ItemStack(QuicklyItems.SULFOR, 4)));
public static final Block ORENETHERSULFOR = registerBlock("orenethersulfor",
properties -> new BlockOre(properties.strength(2.0f), null, new ItemStack(QuicklyItems.SULFOR)));
properties -> new BlockOre(properties.strength(2.0f), new ItemStack(QuicklyItems.SULFOR)));
public static final Block ORESALPETER = registerBlock("oresalpeter",
properties -> new BlockOre(properties.strength(1.9f), null, new ItemStack(QuicklyItems.SALPETER, 2)));
properties -> new BlockOre(properties.strength(1.9f), new ItemStack(QuicklyItems.SALPETER, 2)));
public static final Block ORESANDSALPETER = registerBlock("oresandsalpeter",
properties -> new BlockOre(properties.strength(1.5f), null, new ItemStack(QuicklyItems.SALPETER, 7)));
properties -> new BlockOre(properties.strength(1.5f), new ItemStack(QuicklyItems.SALPETER, 7)));
public static final Block ORESULFOR = registerBlock("oresulfor",
properties -> new BlockOre(properties.strength(1.9f), null, new ItemStack(QuicklyItems.SULFOR)));
properties -> new BlockOre(properties.strength(1.9f), new ItemStack(QuicklyItems.SULFOR)));
public static final Block ORESPEEDPOWDER = registerBlock("orespeedpowder",
properties -> new BlockOre(properties.strength(2.0f), null, new ItemStack(QuicklyItems.SPEEDPOWDER)));
properties -> new BlockOre(properties.strength(2.0f), new ItemStack(QuicklyItems.SPEEDPOWDER)));
public static final Block OREDEEPSLATESPEEDPOWDER = registerBlock("oredeepslatespeedpowder",
properties -> new BlockOre(properties.strength(2.1f), null, new ItemStack(QuicklyItems.SPEEDPOWDER, 2)));
properties -> new BlockOre(properties.strength(2.1f), new ItemStack(QuicklyItems.SPEEDPOWDER, 2)));
public static final Block SALPETERBLOCK = registerBlock("blocksalpeter",
properties -> new BlockOre(properties.strength(1.5f), null, new ItemStack(QuicklyItems.SALPETER, 9)));
properties -> new BlockOre(properties.strength(1.5f), new ItemStack(QuicklyItems.SALPETER, 9)));
public static final Block SULFORBLOCK = registerBlock("blocksulfor",
properties -> new BlockOre(properties.strength(1.5f), null, new ItemStack(QuicklyItems.SULFOR, 9)));
properties -> new BlockOre(properties.strength(1.5f), new ItemStack(QuicklyItems.SULFOR, 9)));
private static final Block registerBlock(String name, Properties properties) {
return QuicklyBlocks.registerBlock(name, properties, p -> new Block(p));

View File

@@ -20,7 +20,7 @@ public class Plant extends Item {
private String plantName;
public Plant(QP properties) {
public Plant(QIP properties) {
super(properties);
this.plantName = properties.getBlockName();
}

View File

@@ -23,7 +23,7 @@ public class QAxe extends AxeItem implements ToolRangeable {
private final HarvestRange range;
public QAxe(QP properties) {
public QAxe(QIP 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();
}

View File

@@ -27,9 +27,9 @@ import net.minecraft.world.phys.BlockHitResult;
*/
public class QHoe extends HoeItem implements ToolRangeable {
public QP properties;
public QIP properties;
public QHoe(QP properties) {
public QHoe(QIP 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;
}

View File

@@ -11,60 +11,60 @@ import net.minecraft.world.item.equipment.ArmorType;
* @author jotty
*
*/
public class QP extends Item.Properties {
public class QIP 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();
public static final QIP of(Integer xRange, Integer yRange, Integer zRange, Integer durability) {
QIP properties = new QIP();
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();
public static final QIP of(Item fallbackItem, Integer harvestRange, Integer durability) {
QIP properties = new QIP();
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();
public static final QIP of(Integer harvestRange, Integer durability) {
QIP properties = new QIP();
properties.setHarvestRange(new HarvestRange(harvestRange));
properties.setDurability(durability);
return properties;
}
public static QP of(Integer minDrops) {
QP properties = new QP();
public static QIP of(Integer minDrops) {
QIP properties = new QIP();
properties.setMinDrops(minDrops);
return properties;
}
public static QP of(String blockName) {
QP properties = new QP();
public static QIP of(String blockName) {
QIP properties = new QIP();
properties.setBlockName(blockName);
return properties;
}
@Override
public QP humanoidArmor(ArmorMaterial material, ArmorType type) {
public QIP humanoidArmor(ArmorMaterial material, ArmorType type) {
super.humanoidArmor(material, type);
return this;
}
@Override
public QP stacksTo(int max) {
public QIP stacksTo(int max) {
super.stacksTo(max);
return this;
}
public final QP setVanilla(ResourceKey<Item> id, Identifier modelId) {
public final QIP setVanilla(ResourceKey<Item> id, Identifier modelId) {
super.setId(id);
super.modelId(modelId);
super.useItemDescriptionPrefix();

View File

@@ -20,7 +20,7 @@ import net.minecraft.world.level.block.state.BlockState;
public class QPickaxe extends Item implements ToolRangeable {
private HarvestRange range;
public QPickaxe(QP properties) {
public QPickaxe(QIP 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();
}

View File

@@ -25,7 +25,7 @@ import net.minecraft.world.phys.Vec3;
public class QShears extends ShearsItem {
private final Integer minimum;
public QShears(QP properties) {
public QShears(QIP properties) {
super(properties.component(DataComponents.TOOL, ShearsItem.createToolProperties()));
this.minimum = properties.getMinDrops();
}

View File

@@ -21,7 +21,7 @@ import net.minecraft.world.level.block.state.BlockState;
public class QShovel extends ShovelItem implements ToolRangeable {
public HarvestRange range;
public QShovel(QP properties) {
public QShovel(QIP 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();
}

View File

@@ -13,9 +13,9 @@ import net.minecraft.world.level.block.Blocks;
*
*/
public class QWaterHoe extends QHoe {
private QP properties;
private QIP properties;
public QWaterHoe(QP properties) {
public QWaterHoe(QIP properties) {
super(properties);
this.properties = properties;
}

View File

@@ -22,10 +22,10 @@ public class QuicklyItems {
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", QP.of("blockcottonplant"), Plant::new);
public static final Item COTTONSEED = registerItem("cottonseed", QIP.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", QP.of("blockcanolaplant"), Plant::new);
public static final Item CANOLASEED = registerItem("canolaseed", QIP.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");
@@ -49,23 +49,23 @@ public class QuicklyItems {
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),
public static final Item SPEEDAXE = registerItem("speedpowderaxe", QIP.of(32, 64, 32, SPEED_DURATION), QAxe::new);
public static final Item SPEEDHOE = registerItem("speedpowderhoe", QIP.of(2, SPEED_DURATION), QHoe::new);
public static final Item SPEEDPICKAXE = registerItem("speedpowderpickaxe", QIP.of(3, SPEED_DURATION), QPickaxe::new);
public static final Item SPEEDSHEARS = registerItem("speedpowdershears", QIP.of(1), QShears::new);
public static final Item SPEEDSHOVEL = registerItem("speedpowdershovel", QIP.of(3, SPEED_DURATION), QShovel::new);
public static final Item SPEEDWATERHOE = registerItem("speedpowderwaterhoe", QIP.of(SPEEDHOE, 2, SPEED_DURATION),
QWaterHoe::new);
public static final Item QUICKIEAXE = registerItem("quickiepowderaxe", QP.of(64, 128, 64, QUICKIE_DURATION),
public static final Item QUICKIEAXE = registerItem("quickiepowderaxe", QIP.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),
public static final Item QUICKIEHOE = registerItem("quickiepowderhoe", QIP.of(4, QUICKIE_DURATION), QHoe::new);
public static final Item QUICKIEPICKAXE = registerItem("quickiepowderpickaxe", QIP.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),
public static final Item QUICKIESHEARS = registerItem("quickiepowdershears", QIP.of(3), QShears::new);
public static final Item QUICKIESHOVEL = registerItem("quickiepowdershovel", QIP.of(6, QUICKIE_DURATION),
QShovel::new);
public static final Item QUICKIEWATERHOE = registerItem("quickiepowderwaterhoe",
QP.of(QUICKIEHOE, 4, QUICKIE_DURATION), QWaterHoe::new);
QIP.of(QUICKIEHOE, 4, QUICKIE_DURATION), QWaterHoe::new);
// armor
public static final Item ARMOR_TURQUOISE_BOOTS = registerItem("turquoise_boots", ArmorType.BOOTS);
@@ -75,22 +75,22 @@ public class QuicklyItems {
private static final Item registerItem(String name, ArmorType armorType) {
return QuicklyItems.registerItem(name,
new QP().stacksTo(1).humanoidArmor(ModArmorMaterials.TURQUOISE_ARMOR_MATERIAL, armorType));
new QIP().stacksTo(1).humanoidArmor(ModArmorMaterials.TURQUOISE_ARMOR_MATERIAL, armorType));
}
private static final Item registerItem(String name) {
return QuicklyItems.registerItem(name, new QP());
return QuicklyItems.registerItem(name, new QIP());
}
private static final Item registerItem(String name, QP properties) {
private static final Item registerItem(String name, QIP properties) {
return QuicklyItems.registerItem(name, properties, Item::new);
}
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, Function<QIP, Item> function) {
return QuicklyItems.registerItem(name, new QIP(), function);
}
private static final Item registerItem(String name, QP properties, Function<QP, Item> function) {
private static final Item registerItem(String name, QIP properties, Function<QIP, Item> function) {
Identifier identifier = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, name);
Item item = function.apply(properties.setVanilla(ResourceKey.create(Registries.ITEM, identifier), identifier));
return Registry.register(BuiltInRegistries.ITEM, identifier, item);