fix #1
This commit is contained in:
@@ -7,14 +7,14 @@ org.gradle.configuration-cache=false
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/develop
|
# check these on https://fabricmc.net/develop
|
||||||
minecraft_version=26.1-snapshot-2
|
minecraft_version=26.1-snapshot-3
|
||||||
loader_version=0.18.4
|
loader_version=0.18.4
|
||||||
loom_version=1.14-SNAPSHOT
|
loom_version=1.14-SNAPSHOT
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=26.1.1
|
mod_version=26.1.2
|
||||||
maven_group=de.jottyfan.minecraft
|
maven_group=de.jottyfan.minecraft
|
||||||
archives_base_name=quickly
|
archives_base_name=quickly
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_api_version=0.141.2+26.1
|
fabric_api_version=0.141.3+26.1
|
||||||
@@ -3,6 +3,8 @@ package de.jottyfan.minecraft.block;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import de.jottyfan.minecraft.item.QuicklyItems;
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
@@ -15,16 +17,19 @@ import net.minecraft.world.level.storage.loot.LootParams.Builder;
|
|||||||
*/
|
*/
|
||||||
public class BlockDrops extends Block {
|
public class BlockDrops extends Block {
|
||||||
|
|
||||||
private ItemStack dropItems;
|
private Identifier dropItem;
|
||||||
|
private Integer count;
|
||||||
|
|
||||||
public BlockDrops(Properties properties, ItemStack dropItems) {
|
public BlockDrops(Properties properties, Identifier dropItem, Integer count) {
|
||||||
super(properties);
|
super(properties);
|
||||||
this.dropItems = dropItems;
|
this.dropItem = dropItem;
|
||||||
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<ItemStack> getDrops(BlockState state, Builder builder) {
|
protected List<ItemStack> getDrops(BlockState state, Builder builder) {
|
||||||
ItemStack droppable = dropItems == null ? new ItemStack(this.asItem()) : dropItems;
|
ItemStack droppable = count == null || count < 1 || dropItem == null ? new ItemStack(this.asItem())
|
||||||
|
: new ItemStack(QuicklyItems.of(dropItem), count);
|
||||||
return Arrays.asList(new ItemStack[] { droppable });
|
return Arrays.asList(new ItemStack[] { droppable });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package de.jottyfan.minecraft.block;
|
package de.jottyfan.minecraft.block;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import de.jottyfan.minecraft.item.QuicklyItems;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.entity.projectile.Projectile;
|
import net.minecraft.world.entity.projectile.Projectile;
|
||||||
@@ -22,14 +24,14 @@ import net.minecraft.world.phys.BlockHitResult;
|
|||||||
public class BlockOre extends Block {
|
public class BlockOre extends Block {
|
||||||
|
|
||||||
private SoundEvent soundEvent;
|
private SoundEvent soundEvent;
|
||||||
private ItemStack[] dropItems;
|
private Identifier[] dropItems;
|
||||||
|
|
||||||
public BlockOre(Properties properties, ItemStack... dropItems) {
|
public BlockOre(Properties properties, Identifier... dropItems) {
|
||||||
super(properties.requiresCorrectToolForDrops());
|
super(properties.requiresCorrectToolForDrops());
|
||||||
this.dropItems = dropItems;
|
this.dropItems = dropItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockOre(Properties properties, SoundEvent soundEvent, ItemStack... dropItems) {
|
public BlockOre(Properties properties, SoundEvent soundEvent, Identifier... dropItems) {
|
||||||
super(properties.requiresCorrectToolForDrops());
|
super(properties.requiresCorrectToolForDrops());
|
||||||
this.soundEvent = soundEvent;
|
this.soundEvent = soundEvent;
|
||||||
this.dropItems = dropItems;
|
this.dropItems = dropItems;
|
||||||
@@ -37,8 +39,15 @@ public class BlockOre extends Block {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<ItemStack> getDrops(BlockState state, Builder builder) {
|
protected List<ItemStack> getDrops(BlockState state, Builder builder) {
|
||||||
ItemStack[] droppable = dropItems == null ? new ItemStack[] { new ItemStack(this.asItem()) } : dropItems;
|
List<ItemStack> list = new ArrayList<>();
|
||||||
return Arrays.asList(droppable);
|
if (dropItems == null || dropItems.length < 1) {
|
||||||
|
list.add(new ItemStack(state.getBlock().asItem()));
|
||||||
|
} else {
|
||||||
|
for (Identifier identifier : dropItems) {
|
||||||
|
list.add(new ItemStack(QuicklyItems.of(identifier)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package de.jottyfan.minecraft.block;
|
package de.jottyfan.minecraft.block;
|
||||||
|
|
||||||
import de.jottyfan.minecraft.Quickly;
|
import de.jottyfan.minecraft.item.QuicklyItems;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
import net.minecraft.world.Containers;
|
import net.minecraft.world.Containers;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.ItemLike;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.CropBlock;
|
import net.minecraft.world.level.block.CropBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
@@ -21,21 +20,21 @@ import net.minecraft.world.phys.BlockHitResult;
|
|||||||
*/
|
*/
|
||||||
public class BlockPlant extends CropBlock {
|
public class BlockPlant extends CropBlock {
|
||||||
|
|
||||||
private String seedName;
|
private Identifier seedName;
|
||||||
private String fruitName;
|
private Identifier fruitName;
|
||||||
|
|
||||||
public BlockPlant(Properties properties, String seedName, String fruitName) {
|
public BlockPlant(Properties properties, Identifier seedName, Identifier fruitName) {
|
||||||
super(properties);
|
super(properties);
|
||||||
this.seedName = seedName;
|
this.seedName = seedName;
|
||||||
this.fruitName = fruitName;
|
this.fruitName = fruitName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item getSeed() {
|
public ItemLike getSeed() {
|
||||||
return BuiltInRegistries.ITEM.getValue(Identifier.fromNamespaceAndPath(Quickly.MOD_ID, seedName));
|
return QuicklyItems.of(seedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item getFruit() {
|
public ItemLike getFruit() {
|
||||||
return BuiltInRegistries.ITEM.getValue(Identifier.fromNamespaceAndPath(Quickly.MOD_ID, fruitName));
|
return QuicklyItems.of(fruitName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package de.jottyfan.minecraft.block;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import de.jottyfan.minecraft.Quickly;
|
import de.jottyfan.minecraft.Quickly;
|
||||||
import de.jottyfan.minecraft.item.QuicklyItems;
|
import de.jottyfan.minecraft.name.ID;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
@@ -12,8 +12,6 @@ import net.minecraft.resources.ResourceKey;
|
|||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.item.Items;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
@@ -25,65 +23,63 @@ import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class QuicklyBlocks {
|
public class QuicklyBlocks {
|
||||||
public static final Block KELPBUNDLE = registerBlock("kelpbundle",
|
public static final Block KELPBUNDLE = registerBlock(ID.KELPBUNDLE,
|
||||||
Properties.of().instabreak().sound(SoundType.WET_GRASS).strength(0.1f).friction(0.95f));
|
Properties.of().instabreak().sound(SoundType.WET_GRASS).strength(0.1f).friction(0.95f));
|
||||||
public static final Block TURQUOISEBLOCK = registerBlock("blockturquoise", Properties.of().strength(1.5f));
|
public static final Block TURQUOISEBLOCK = registerBlock(ID.BLOCKTURQUOISE, Properties.of().strength(1.5f));
|
||||||
public static final Block ORETURQUOISE = registerBlock("oreturquoise",
|
public static final Block ORETURQUOISE = registerBlock(ID.ORETURQUOISE,
|
||||||
properties -> new BlockOre(properties.strength(3.0f).sound(SoundType.AMETHYST), SoundEvents.AMETHYST_BLOCK_CHIME,
|
properties -> new BlockOre(properties.strength(3.0f).sound(SoundType.AMETHYST), SoundEvents.AMETHYST_BLOCK_CHIME,
|
||||||
new ItemStack(QuicklyItems.RAWTURQUOISE)));
|
ID.RAWTURQUOISE));
|
||||||
public static final Block OREDEEPSLATETURQUOISE = registerBlock("oredeepslateturquoise",
|
public static final Block OREDEEPSLATETURQUOISE = registerBlock(ID.OREDEEPSLATETURQUOISE,
|
||||||
properties -> new BlockOre(properties, SoundEvents.AMETHYST_BLOCK_CHIME,
|
properties -> new BlockOre(properties, SoundEvents.AMETHYST_BLOCK_CHIME, ID.RAWTURQUOISE));
|
||||||
new ItemStack(QuicklyItems.RAWTURQUOISE, 2)));
|
public static final Block COTTONPLANT = registerBlock(ID.BLOCKCOTTONPLANT, Properties.ofFullCopy(Blocks.WHEAT),
|
||||||
public static final Block COTTONPLANT = registerBlock("blockcottonplant", Properties.ofFullCopy(Blocks.WHEAT),
|
properties -> new BlockPlant(properties, ID.COTTONSEED, ID.COTTON));
|
||||||
properties -> new BlockPlant(properties, "cottonseed", "cotton"));
|
public static final Block CANOLAPLANT = registerBlock(ID.BLOCKCANOLAPLANT, Properties.ofFullCopy(Blocks.WHEAT),
|
||||||
public static final Block CANOLAPLANT = registerBlock("blockcanolaplant", Properties.ofFullCopy(Blocks.WHEAT),
|
properties -> new BlockPlant(properties, ID.CANOLASEED, ID.CANOLA));
|
||||||
properties -> new BlockPlant(properties, "canolaseed", "canola"));
|
public static final Block LAVAHOARDER = registerBlock(ID.LAVAHOARDER,
|
||||||
public static final Block LAVAHOARDER = registerBlock("lavahoarder",
|
Properties.of().strength(2.5f).lightLevel(state -> state.getValue(Lavahoarder.FILLED) ? 15 : 0),
|
||||||
Properties.of().strength(2.5f).lightLevel(state -> state.getValue(Lavahoarder.FILLED) ? 15 : 0), Lavahoarder::new);
|
Lavahoarder::new);
|
||||||
public static final Block QUICKIEPOWDER = registerBlock("blockquickiepowder",
|
public static final Block QUICKIEPOWDER = registerBlock(ID.BLOCKQUICKIEPOWDER,
|
||||||
properties -> new BlockDrops(properties, new ItemStack(QuicklyItems.QUICKIEPOWDER, 9)));
|
properties -> new BlockDrops(properties, ID.QUICKIEPOWDER, 9));
|
||||||
public static final Block SPEEDPOWDER = registerBlock("blockspeedpowder",
|
public static final Block SPEEDPOWDER = registerBlock(ID.BLOCKSPEEDPOWDER,
|
||||||
properties -> new BlockDrops(properties, new ItemStack(QuicklyItems.SPEEDPOWDER, 9)));
|
properties -> new BlockDrops(properties, ID.SPEEDPOWDER, 9));
|
||||||
public static final Block MONSTERHOARDER = registerBlock("monsterhoarder", Monsterhoarder::new);
|
public static final Block MONSTERHOARDER = registerBlock(ID.MONSTERHOARDER, Monsterhoarder::new);
|
||||||
public static final Block ITEMHOARDER = registerBlock("itemhoarder", Itemhoarder::new);
|
public static final Block ITEMHOARDER = registerBlock(ID.ITEMHOARDER, Itemhoarder::new);
|
||||||
public static final Block DRILL = registerBlock("drill", BlockDrill::new);
|
public static final Block DRILL = registerBlock(ID.DRILL, BlockDrill::new);
|
||||||
public static final Block STACKER = registerBlock("blockstacker",
|
public static final Block STACKER = registerBlock(ID.BLOCKSTACKER,
|
||||||
properties -> new BlockStacker(properties.strength(2.5f)));
|
properties -> new BlockStacker(properties.strength(2.5f)));
|
||||||
public static final Block DIRTSALPETER = registerBlock("dirtsalpeter",
|
public static final Block DIRTSALPETER = registerBlock(ID.DIRTSALPETER,
|
||||||
properties -> new BlockOre(properties.strength(2.2f), new ItemStack(QuicklyItems.SALPETER, 1),
|
properties -> new BlockOre(properties.strength(2.2f), ID.SALPETER));
|
||||||
new ItemStack(Items.DIRT)));
|
public static final Block SANDSALPETER = registerBlock(ID.SANDSALPETER,
|
||||||
public static final Block SANDSALPETER = registerBlock("sandsalpeter",
|
properties -> new BlockOre(properties.strength(1.5f), ID.SALPETER));
|
||||||
properties -> new BlockOre(properties.strength(1.5f), new ItemStack(QuicklyItems.SALPETER, 2),
|
public static final Block OREDEEPSLATESULFOR = registerBlock(ID.OREDEEPSLATESULFOR,
|
||||||
new ItemStack(Items.SAND)));
|
properties -> new BlockOre(properties.strength(2.0f), ID.SULFOR));
|
||||||
public static final Block OREDEEPSLATESULFOR = registerBlock("oredeepslatesulfor",
|
public static final Block ORENETHERSULFOR = registerBlock(ID.ORENETHERSULFOR,
|
||||||
properties -> new BlockOre(properties.strength(2.0f), new ItemStack(QuicklyItems.SULFOR, 4)));
|
properties -> new BlockOre(properties.strength(2.0f), ID.SULFOR));
|
||||||
public static final Block ORENETHERSULFOR = registerBlock("orenethersulfor",
|
public static final Block ORESALPETER = registerBlock(ID.ORESALPETER,
|
||||||
properties -> new BlockOre(properties.strength(2.0f), new ItemStack(QuicklyItems.SULFOR)));
|
properties -> new BlockOre(properties.strength(1.9f), ID.SALPETER));
|
||||||
public static final Block ORESALPETER = registerBlock("oresalpeter",
|
public static final Block ORESANDSALPETER = registerBlock(ID.ORESANDSALPETER,
|
||||||
properties -> new BlockOre(properties.strength(1.9f), new ItemStack(QuicklyItems.SALPETER, 2)));
|
properties -> new BlockOre(properties.strength(1.5f), ID.SALPETER));
|
||||||
public static final Block ORESANDSALPETER = registerBlock("oresandsalpeter",
|
public static final Block ORESULFOR = registerBlock(ID.ORESULFOR,
|
||||||
properties -> new BlockOre(properties.strength(1.5f), new ItemStack(QuicklyItems.SALPETER, 7)));
|
properties -> new BlockOre(properties.strength(1.9f), ID.SULFOR));
|
||||||
public static final Block ORESULFOR = registerBlock("oresulfor",
|
public static final Block ORESPEEDPOWDER = registerBlock(ID.ORESPEEDPOWDER,
|
||||||
properties -> new BlockOre(properties.strength(1.9f), new ItemStack(QuicklyItems.SULFOR)));
|
properties -> new BlockOre(properties.strength(2.0f), ID.SPEEDPOWDER));
|
||||||
public static final Block ORESPEEDPOWDER = registerBlock("orespeedpowder",
|
public static final Block OREDEEPSLATESPEEDPOWDER = registerBlock(ID.OREDEEPSLATESPEEDPOWDER,
|
||||||
properties -> new BlockOre(properties.strength(2.0f), new ItemStack(QuicklyItems.SPEEDPOWDER)));
|
properties -> new BlockOre(properties.strength(2.1f), ID.SPEEDPOWDER));
|
||||||
public static final Block OREDEEPSLATESPEEDPOWDER = registerBlock("oredeepslatespeedpowder",
|
public static final Block SALPETERBLOCK = registerBlock(ID.BLOCKSALPETER,
|
||||||
properties -> new BlockOre(properties.strength(2.1f), new ItemStack(QuicklyItems.SPEEDPOWDER, 2)));
|
properties -> new BlockOre(properties.strength(1.5f), ID.SALPETER));
|
||||||
public static final Block SALPETERBLOCK = registerBlock("blocksalpeter",
|
public static final Block SULFORBLOCK = registerBlock(ID.BLOCKSULFOR,
|
||||||
properties -> new BlockOre(properties.strength(1.5f), new ItemStack(QuicklyItems.SALPETER, 9)));
|
properties -> new BlockOre(properties.strength(1.5f), ID.SULFOR));
|
||||||
public static final Block SULFORBLOCK = registerBlock("blocksulfor",
|
|
||||||
properties -> new BlockOre(properties.strength(1.5f), new ItemStack(QuicklyItems.SULFOR, 9)));
|
|
||||||
|
|
||||||
private static final Block registerBlock(String name, Properties properties) {
|
private static final Block registerBlock(Identifier identifier, Properties properties) {
|
||||||
return QuicklyBlocks.registerBlock(name, properties, p -> new Block(p));
|
return QuicklyBlocks.registerBlock(identifier, properties, p -> new Block(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Block registerBlock(String name, Function<Properties, Block> function) {
|
private static final Block registerBlock(Identifier identifier, Function<Properties, Block> function) {
|
||||||
return QuicklyBlocks.registerBlock(name, Properties.of(), function);
|
return QuicklyBlocks.registerBlock(identifier, Properties.of(), function);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Block registerBlock(String name, Properties properties, Function<Properties, Block> function) {
|
private static final Block registerBlock(Identifier identifier, Properties properties,
|
||||||
Identifier identifier = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, name);
|
Function<Properties, Block> function) {
|
||||||
Block block = function.apply(properties.setId(ResourceKey.create(Registries.BLOCK, identifier)));
|
Block block = function.apply(properties.setId(ResourceKey.create(Registries.BLOCK, identifier)));
|
||||||
Registry.register(BuiltInRegistries.BLOCK, identifier, block);
|
Registry.register(BuiltInRegistries.BLOCK, identifier, block);
|
||||||
BlockItem blockItem = new BlockItem(block, new Item.Properties()
|
BlockItem blockItem = new BlockItem(block, new Item.Properties()
|
||||||
@@ -92,6 +88,17 @@ public class QuicklyBlocks {
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the block from the identifier
|
||||||
|
*
|
||||||
|
* @param identifier the identifier
|
||||||
|
* @return the block or null
|
||||||
|
*/
|
||||||
|
public static final Block of(Identifier identifier) {
|
||||||
|
return BuiltInRegistries.BLOCK.getValue(identifier);
|
||||||
|
}
|
||||||
|
|
||||||
public static void registerModBlocks() {
|
public static void registerModBlocks() {
|
||||||
|
Quickly.LOGGER.info("forbid the optimizer to ignore static block registration");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import net.minecraft.world.Container;
|
|||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
@@ -39,16 +38,12 @@ public class ItemHoarderBlockEntity extends BlockEntity implements Container {
|
|||||||
super(QuicklyBlockEntity.BLOCKENTITY_ITEMHOARDER, pos, state);
|
super(QuicklyBlockEntity.BLOCKENTITY_ITEMHOARDER, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String getItemId(Item item) {
|
|
||||||
return item.getName().getString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final static boolean setStackToSlots(ItemStack stack, Map<String, ItemStack> stacks) {
|
public final static boolean setStackToSlots(ItemStack stack, Map<String, ItemStack> stacks) {
|
||||||
if (stack.isEmpty()) {
|
if (stack.isEmpty()) {
|
||||||
Quickly.LOGGER.info("FATAL!!! tried to set empty stack. Check your code!");
|
Quickly.LOGGER.info("FATAL!!! tried to set empty stack. Check your code!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String key = getItemId(stack.getItem());
|
String key = stack.getItemName().getString();
|
||||||
ItemStack s = stacks.get(key);
|
ItemStack s = stacks.get(key);
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
stacks.put(key, stack);
|
stacks.put(key, stack);
|
||||||
@@ -162,11 +157,11 @@ public class ItemHoarderBlockEntity extends BlockEntity implements Container {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setItem(int slot, ItemStack itemStack) {
|
public void setItem(int slot, ItemStack itemStack) {
|
||||||
ItemStack found = stacks.get(itemStack.getItem().getName().getString());
|
ItemStack found = stacks.get(itemStack.getItemName().getString());
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
found.grow(itemStack.getCount());
|
found.grow(itemStack.getCount());
|
||||||
} else if (!itemStack.isEmpty()) {
|
} else if (!itemStack.isEmpty()) {
|
||||||
stacks.put(itemStack.getItem().getName().getString(), itemStack);
|
stacks.put(itemStack.getItemName().getString(), itemStack);
|
||||||
}
|
}
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,5 @@ public class QuicklyBlockEntity<T extends BlockEntity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final void registerBlockEntities() {
|
public static final void registerBlockEntities() {
|
||||||
// dummy
|
Quickly.LOGGER.info("forbid the optimizer to ignore static block entity registration"); }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,10 @@ package de.jottyfan.minecraft.event;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.jottyfan.minecraft.Quickly;
|
|
||||||
import de.jottyfan.minecraft.item.HarvestRange;
|
import de.jottyfan.minecraft.item.HarvestRange;
|
||||||
import de.jottyfan.minecraft.item.QuicklyItems;
|
import de.jottyfan.minecraft.item.QuicklyItems;
|
||||||
import de.jottyfan.minecraft.item.ToolRangeable;
|
import de.jottyfan.minecraft.item.ToolRangeable;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
|
||||||
import net.minecraft.world.entity.ExperienceOrb;
|
import net.minecraft.world.entity.ExperienceOrb;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
@@ -80,38 +78,32 @@ public class EventBlockBreak {
|
|||||||
BlockPos pos, Player player) {
|
BlockPos pos, Player player) {
|
||||||
List<Block> validBlocks = tool.getBlockList(currentBlock);
|
List<Block> validBlocks = tool.getBlockList(currentBlock);
|
||||||
HarvestRange range = tool.getRange(itemStack);
|
HarvestRange range = tool.getRange(itemStack);
|
||||||
if (tool instanceof Item) {
|
List<String> visitedBlocks = new ArrayList<>();
|
||||||
Item toolItem = (Item) tool; // a rangeable tool should always be an item
|
if (QuicklyItems.SPEEDAXE == tool) {
|
||||||
List<String> visitedBlocks = new ArrayList<>();
|
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS,
|
||||||
if (QuicklyItems.SPEEDAXE.getName().equals(toolItem.getName())) {
|
player, true);
|
||||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS,
|
} else if (QuicklyItems.SPEEDPICKAXE == tool) {
|
||||||
player, true);
|
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player,
|
||||||
} else if (QuicklyItems.SPEEDPICKAXE.getName().equals(toolItem.getName())) {
|
false);
|
||||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
} else if (QuicklyItems.SPEEDSHOVEL == tool) {
|
||||||
player, false);
|
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player,
|
||||||
} else if (QuicklyItems.SPEEDSHOVEL.getName().equals(toolItem.getName())) {
|
false);
|
||||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
} else if (QuicklyItems.SPEEDHOE == tool) {
|
||||||
player, false);
|
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player,
|
||||||
} else if (QuicklyItems.SPEEDHOE.getName().equals(toolItem.getName())) {
|
false);
|
||||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
} else if (QuicklyItems.QUICKIEAXE == tool) {
|
||||||
player, false);
|
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS,
|
||||||
} else if (QuicklyItems.QUICKIEAXE.getName().equals(toolItem.getName())) {
|
player, true);
|
||||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS,
|
} else if (QuicklyItems.QUICKIEPICKAXE == tool) {
|
||||||
player, true);
|
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player,
|
||||||
} else if (QuicklyItems.QUICKIEPICKAXE.getName().equals(toolItem.getName())) {
|
false);
|
||||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
} else if (QuicklyItems.QUICKIESHOVEL == tool) {
|
||||||
player, false);
|
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player,
|
||||||
} else if (QuicklyItems.QUICKIESHOVEL.getName().equals(toolItem.getName())) {
|
false);
|
||||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
} else if (QuicklyItems.QUICKIEHOE == tool) {
|
||||||
player, false);
|
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player,
|
||||||
} else if (QuicklyItems.QUICKIEHOE.getName().equals(toolItem.getName())) {
|
false);
|
||||||
return breakBlockRecursive(visitedBlocks, level, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
|
|
||||||
player, false);
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Quickly.LOGGER.warn("using a tool that is not an item - no rangeable operations are possible.");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +138,7 @@ public class EventBlockBreak {
|
|||||||
Block currentBlock = blockState.getBlock();
|
Block currentBlock = blockState.getBlock();
|
||||||
if (validBlocks.contains(currentBlock)) {
|
if (validBlocks.contains(currentBlock)) {
|
||||||
// if (!ignoreSpawn) {
|
// if (!ignoreSpawn) {
|
||||||
Block.dropResources(blockState, level, pos); // includes xorbs
|
Block.dropResources(blockState, level, pos); // includes xorbs
|
||||||
// }
|
// }
|
||||||
affected += 1;
|
affected += 1;
|
||||||
level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
||||||
@@ -172,18 +164,18 @@ public class EventBlockBreak {
|
|||||||
blockBreakDirection, player, breakLeaves);
|
blockBreakDirection, player, breakLeaves);
|
||||||
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().north(), tool, nextRadius,
|
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().north(), tool, nextRadius,
|
||||||
blockBreakDirection, player, breakLeaves);
|
blockBreakDirection, player, breakLeaves);
|
||||||
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().north().east(), tool, nextRadius,
|
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().north().east(), tool,
|
||||||
blockBreakDirection, player, breakLeaves);
|
nextRadius, blockBreakDirection, player, breakLeaves);
|
||||||
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().north().west(), tool, nextRadius,
|
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().north().west(), tool,
|
||||||
blockBreakDirection, player, breakLeaves);
|
nextRadius, blockBreakDirection, player, breakLeaves);
|
||||||
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().east(), tool, nextRadius,
|
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().east(), tool, nextRadius,
|
||||||
blockBreakDirection, player, breakLeaves);
|
blockBreakDirection, player, breakLeaves);
|
||||||
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().west(), tool, nextRadius,
|
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().west(), tool, nextRadius,
|
||||||
blockBreakDirection, player, breakLeaves);
|
blockBreakDirection, player, breakLeaves);
|
||||||
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().south().east(), tool, nextRadius,
|
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().south().east(), tool,
|
||||||
blockBreakDirection, player, breakLeaves);
|
nextRadius, blockBreakDirection, player, breakLeaves);
|
||||||
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().south().west(), tool, nextRadius,
|
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().south().west(), tool,
|
||||||
blockBreakDirection, player, breakLeaves);
|
nextRadius, blockBreakDirection, player, breakLeaves);
|
||||||
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().south(), tool, nextRadius,
|
affected += breakBlockRecursive(visitedBlocks, level, validBlocks, pos.above().south(), tool, nextRadius,
|
||||||
blockBreakDirection, player, breakLeaves);
|
blockBreakDirection, player, breakLeaves);
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,14 @@ import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
|
|||||||
public class QuicklyEvents {
|
public class QuicklyEvents {
|
||||||
public static final void registerBlockBreak() {
|
public static final void registerBlockBreak() {
|
||||||
PlayerBlockBreakEvents.BEFORE.register((world, player, pos, state, blockEntity) -> {
|
PlayerBlockBreakEvents.BEFORE.register((world, player, pos, state, blockEntity) -> {
|
||||||
if (new EventBlockBreak().doBreakBlock(world, pos, state, player, state.getBlock())) {
|
if (!world.isClientSide()) {
|
||||||
return false;
|
if (new EventBlockBreak().doBreakBlock(world, pos, state, player, state.getBlock())) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package de.jottyfan.minecraft.item;
|
package de.jottyfan.minecraft.item;
|
||||||
|
|
||||||
import de.jottyfan.minecraft.Quickly;
|
import de.jottyfan.minecraft.block.QuicklyBlocks;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
@@ -18,15 +17,15 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||||||
*/
|
*/
|
||||||
public class Plant extends Item {
|
public class Plant extends Item {
|
||||||
|
|
||||||
private String plantName;
|
private Identifier plantId;
|
||||||
|
|
||||||
public Plant(QIP properties) {
|
public Plant(QIP properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
this.plantName = properties.getBlockName();
|
this.plantId = properties.getBlockId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Block getPlant() {
|
private Block getPlant() {
|
||||||
return BuiltInRegistries.BLOCK.getValue(Identifier.fromNamespaceAndPath(Quickly.MOD_ID, plantName));
|
return QuicklyBlocks.of(plantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class QHoe extends HoeItem implements ToolRangeable {
|
|||||||
CropBlock cBlock = (CropBlock) block;
|
CropBlock cBlock = (CropBlock) block;
|
||||||
if (cBlock.isMaxAge(blockState)) {
|
if (cBlock.isMaxAge(blockState)) {
|
||||||
Block.dropResources(blockState, level, pos);
|
Block.dropResources(blockState, level, pos);
|
||||||
level.setBlockAndUpdate(pos, cBlock.defaultBlockState().setValue(CropBlock.AGE, 0));
|
level.setBlockAndUpdate(pos, cBlock.defaultBlockState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class QIP extends Item.Properties {
|
|||||||
private HarvestRange harvestRange;
|
private HarvestRange harvestRange;
|
||||||
private Integer durability;
|
private Integer durability;
|
||||||
private Integer minDrops;
|
private Integer minDrops;
|
||||||
private String blockName;
|
private Identifier blockId;
|
||||||
|
|
||||||
public static final QIP of(Integer xRange, Integer yRange, Integer zRange, Integer durability) {
|
public static final QIP of(Integer xRange, Integer yRange, Integer zRange, Integer durability) {
|
||||||
QIP properties = new QIP();
|
QIP properties = new QIP();
|
||||||
@@ -46,9 +46,9 @@ public class QIP extends Item.Properties {
|
|||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static QIP of(String blockName) {
|
public static QIP of(Identifier blockId) {
|
||||||
QIP properties = new QIP();
|
QIP properties = new QIP();
|
||||||
properties.setBlockName(blockName);
|
properties.setBlockId(blockId);
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,16 +122,16 @@ public class QIP extends Item.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the blockName
|
* @return the blockId
|
||||||
*/
|
*/
|
||||||
public String getBlockName() {
|
public Identifier getBlockId() {
|
||||||
return blockName;
|
return blockId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param blockName the blockName to set
|
* @param blockId the blockId to set
|
||||||
*/
|
*/
|
||||||
public void setBlockName(String blockName) {
|
public void setBlockId(Identifier blockId) {
|
||||||
this.blockName = blockName;
|
this.blockId = blockId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package de.jottyfan.minecraft.item;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import de.jottyfan.minecraft.Quickly;
|
import de.jottyfan.minecraft.Quickly;
|
||||||
|
import de.jottyfan.minecraft.name.ID;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
@@ -10,6 +11,7 @@ import net.minecraft.resources.Identifier;
|
|||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.equipment.ArmorType;
|
import net.minecraft.world.item.equipment.ArmorType;
|
||||||
|
import net.minecraft.world.level.ItemLike;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -17,31 +19,31 @@ import net.minecraft.world.item.equipment.ArmorType;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class QuicklyItems {
|
public class QuicklyItems {
|
||||||
public static final Item STUB = registerItem("stub", Stub::new);
|
public static final Item STUB = registerItem(ID.STUB, Stub::new);
|
||||||
public static final Item RAWTURQUOISE = registerItem("rawturquoise");
|
public static final Item RAWTURQUOISE = registerItem(ID.RAWTURQUOISE);
|
||||||
public static final Item TURQUOISEINGOT = registerItem("turquoiseingot");
|
public static final Item TURQUOISEINGOT = registerItem(ID.TURQUOISEINGOT);
|
||||||
public static final Item COTTON = registerItem("cotton");
|
public static final Item COTTON = registerItem(ID.COTTON);
|
||||||
public static final Item COTTONPLANT = registerItem("cottonplant");
|
public static final Item COTTONPLANT = registerItem(ID.COTTONPLANT);
|
||||||
public static final Item COTTONSEED = registerItem("cottonseed", QIP.of("blockcottonplant"), Plant::new);
|
public static final Item COTTONSEED = registerItem(ID.COTTONSEED, QIP.of(ID.BLOCKCOTTONPLANT), Plant::new);
|
||||||
public static final Item CANOLA = registerItem("canola");
|
public static final Item CANOLA = registerItem(ID.CANOLA);
|
||||||
public static final Item CANOLAPLANT = registerItem("canolaplant");
|
public static final Item CANOLAPLANT = registerItem(ID.CANOLAPLANT);
|
||||||
public static final Item CANOLASEED = registerItem("canolaseed", QIP.of("blockcanolaplant"), Plant::new);
|
public static final Item CANOLASEED = registerItem(ID.CANOLASEED, QIP.of(ID.BLOCKCANOLAPLANT), Plant::new);
|
||||||
public static final Item CANOLABOTTLE = registerItem("canolabottle");
|
public static final Item CANOLABOTTLE = registerItem(ID.CANOLABOTTLE);
|
||||||
public static final Item CANOLABOTTLESTACK = registerItem("canolabottlestack");
|
public static final Item CANOLABOTTLESTACK = registerItem(ID.CANOLABOTTLESTACK);
|
||||||
public static final Item ROTTENFLESHSTRIPES = registerItem("rotten_flesh_stripes");
|
public static final Item ROTTENFLESHSTRIPES = registerItem(ID.ROTTEN_FLESH_STRIPES);
|
||||||
public static final Item OXIDIZEDCOPPERPOWDER = registerItem("oxidizedcopperpowder");
|
public static final Item OXIDIZEDCOPPERPOWDER = registerItem(ID.OXIDIZEDCOPPERPOWDER);
|
||||||
public static final Item COPPERSTRING = registerItem("copperstring");
|
public static final Item COPPERSTRING = registerItem(ID.COPPERSTRING);
|
||||||
public static final Item COPPERPOWDER = registerItem("copperpowder");
|
public static final Item COPPERPOWDER = registerItem(ID.COPPERPOWDER);
|
||||||
public static final Item COPPERSTUB = registerItem("copperstub");
|
public static final Item COPPERSTUB = registerItem(ID.COPPERSTUB);
|
||||||
public static final Item COPPERSTICK = registerItem("copperstick");
|
public static final Item COPPERSTICK = registerItem(ID.COPPERSTICK);
|
||||||
public static final Item SPEEDPOWDER = registerItem("speedpowder");
|
public static final Item SPEEDPOWDER = registerItem(ID.SPEEDPOWDER);
|
||||||
public static final Item QUICKIEPOWDER = registerItem("quickiepowder");
|
public static final Item QUICKIEPOWDER = registerItem(ID.QUICKIEPOWDER);
|
||||||
public static final Item SPEEDINGOT = registerItem("speedingot");
|
public static final Item SPEEDINGOT = registerItem(ID.SPEEDINGOT);
|
||||||
public static final Item QUICKIEINGOT = registerItem("quickieingot");
|
public static final Item QUICKIEINGOT = registerItem(ID.QUICKIEINGOT);
|
||||||
public static final Item MAGNIFIER = registerItem("magnifier");
|
public static final Item MAGNIFIER = registerItem(ID.MAGNIFIER);
|
||||||
public static final Item SALPETER = registerItem("salpeter");
|
public static final Item SALPETER = registerItem(ID.SALPETER);
|
||||||
public static final Item SULFOR = registerItem("sulfor");
|
public static final Item SULFOR = registerItem(ID.SULFOR);
|
||||||
public static final Item CARROTSTACK = registerItem("carrotstack");
|
public static final Item CARROTSTACK = registerItem(ID.CARROTSTACK);
|
||||||
|
|
||||||
// TODO: rename tools to speedaxe and quickaxe instead of the powder version
|
// TODO: rename tools to speedaxe and quickaxe instead of the powder version
|
||||||
|
|
||||||
@@ -49,53 +51,63 @@ public class QuicklyItems {
|
|||||||
private static final Integer SPEED_DURATION = 800;
|
private static final Integer SPEED_DURATION = 800;
|
||||||
private static final Integer QUICKIE_DURATION = 2400;
|
private static final Integer QUICKIE_DURATION = 2400;
|
||||||
|
|
||||||
public static final Item SPEEDAXE = registerItem("speedpowderaxe", QIP.of(32, 64, 32, SPEED_DURATION), QAxe::new);
|
public static final Item SPEEDAXE = registerItem(ID.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 SPEEDHOE = registerItem(ID.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 SPEEDPICKAXE = registerItem(ID.SPEEDPOWDERPICKAXE, QIP.of(3, SPEED_DURATION), QPickaxe::new);
|
||||||
public static final Item SPEEDSHEARS = registerItem("speedpowdershears", QIP.of(1), QShears::new);
|
public static final Item SPEEDSHEARS = registerItem(ID.SPEEDPOWDERSHEARS, QIP.of(1), QShears::new);
|
||||||
public static final Item SPEEDSHOVEL = registerItem("speedpowdershovel", QIP.of(3, SPEED_DURATION), QShovel::new);
|
public static final Item SPEEDSHOVEL = registerItem(ID.SPEEDPOWDERSHOVEL, QIP.of(3, SPEED_DURATION), QShovel::new);
|
||||||
public static final Item SPEEDWATERHOE = registerItem("speedpowderwaterhoe", QIP.of(SPEEDHOE, 2, SPEED_DURATION),
|
public static final Item SPEEDWATERHOE = registerItem(ID.SPEEDPOWDERWATERHOE, QIP.of(SPEEDHOE, 2, SPEED_DURATION),
|
||||||
QWaterHoe::new);
|
QWaterHoe::new);
|
||||||
public static final Item QUICKIEAXE = registerItem("quickiepowderaxe", QIP.of(64, 128, 64, QUICKIE_DURATION),
|
public static final Item QUICKIEAXE = registerItem(ID.QUICKIEPOWDERAXE, QIP.of(64, 128, 64, QUICKIE_DURATION),
|
||||||
QAxe::new);
|
QAxe::new);
|
||||||
public static final Item QUICKIEHOE = registerItem("quickiepowderhoe", QIP.of(4, QUICKIE_DURATION), QHoe::new);
|
public static final Item QUICKIEHOE = registerItem(ID.QUICKIEPOWDERHOE, QIP.of(4, QUICKIE_DURATION), QHoe::new);
|
||||||
public static final Item QUICKIEPICKAXE = registerItem("quickiepowderpickaxe", QIP.of(6, QUICKIE_DURATION),
|
public static final Item QUICKIEPICKAXE = registerItem(ID.QUICKIEPOWDERPICKAXE, QIP.of(6, QUICKIE_DURATION),
|
||||||
QPickaxe::new);
|
QPickaxe::new);
|
||||||
public static final Item QUICKIESHEARS = registerItem("quickiepowdershears", QIP.of(3), QShears::new);
|
public static final Item QUICKIESHEARS = registerItem(ID.QUICKIEPOWDERSHEARS, QIP.of(3), QShears::new);
|
||||||
public static final Item QUICKIESHOVEL = registerItem("quickiepowdershovel", QIP.of(6, QUICKIE_DURATION),
|
public static final Item QUICKIESHOVEL = registerItem(ID.QUICKIEPOWDERSHOVEL, QIP.of(6, QUICKIE_DURATION),
|
||||||
QShovel::new);
|
QShovel::new);
|
||||||
public static final Item QUICKIEWATERHOE = registerItem("quickiepowderwaterhoe",
|
public static final Item QUICKIEWATERHOE = registerItem(ID.QUICKIEPOWDERWATERHOE,
|
||||||
QIP.of(QUICKIEHOE, 4, QUICKIE_DURATION), QWaterHoe::new);
|
QIP.of(QUICKIEHOE, 4, QUICKIE_DURATION), QWaterHoe::new);
|
||||||
|
|
||||||
// armor
|
// armor
|
||||||
public static final Item ARMOR_TURQUOISE_BOOTS = registerItem("turquoise_boots", ArmorType.BOOTS);
|
public static final Item ARMOR_TURQUOISE_BOOTS = registerItem(ID.TURQUOISE_BOOTS, ArmorType.BOOTS);
|
||||||
public static final Item ARMOR_TURQUOISE_HELMET = registerItem("turquoise_helmet", ArmorType.HELMET);
|
public static final Item ARMOR_TURQUOISE_HELMET = registerItem(ID.TURQUOISE_HELMET, ArmorType.HELMET);
|
||||||
public static final Item ARMOR_TURQUOISE_LEGGINGS = registerItem("turquoise_leggings", ArmorType.LEGGINGS);
|
public static final Item ARMOR_TURQUOISE_LEGGINGS = registerItem(ID.TURQUOISE_LEGGINGS, ArmorType.LEGGINGS);
|
||||||
public static final Item ARMOR_TURQUOISE_CHESTPLATE = registerItem("turquoise_chestplate", ArmorType.CHESTPLATE);
|
public static final Item ARMOR_TURQUOISE_CHESTPLATE = registerItem(ID.TURQUOISE_CHESTPLATE, ArmorType.CHESTPLATE);
|
||||||
|
|
||||||
private static final Item registerItem(String name, ArmorType armorType) {
|
private static final Item registerItem(Identifier identifier, ArmorType armorType) {
|
||||||
return QuicklyItems.registerItem(name,
|
return QuicklyItems.registerItem(identifier,
|
||||||
new QIP().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) {
|
private static final Item registerItem(Identifier identifier) {
|
||||||
return QuicklyItems.registerItem(name, new QIP());
|
return QuicklyItems.registerItem(identifier, new QIP());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Item registerItem(String name, QIP properties) {
|
private static final Item registerItem(Identifier identifier, QIP properties) {
|
||||||
return QuicklyItems.registerItem(name, properties, Item::new);
|
return QuicklyItems.registerItem(identifier, properties, Item::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Item registerItem(String name, Function<QIP, Item> function) {
|
private static final Item registerItem(Identifier identifier, Function<QIP, Item> function) {
|
||||||
return QuicklyItems.registerItem(name, new QIP(), function);
|
return QuicklyItems.registerItem(identifier, new QIP(), function);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Item registerItem(String name, QIP properties, Function<QIP, Item> function) {
|
private static final Item registerItem(Identifier identifier, 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));
|
Item item = function.apply(properties.setVanilla(ResourceKey.create(Registries.ITEM, identifier), identifier));
|
||||||
return Registry.register(BuiltInRegistries.ITEM, identifier, item);
|
return Registry.register(BuiltInRegistries.ITEM, identifier, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void registerModItems() {
|
public static final void registerModItems() {
|
||||||
|
Quickly.LOGGER.info("forbid the optimizer to ignore static item registration");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the item of the identifier or null
|
||||||
|
*
|
||||||
|
* @param identifier the identifier
|
||||||
|
* @return the item or null
|
||||||
|
*/
|
||||||
|
public static final ItemLike of(Identifier identifier) {
|
||||||
|
return BuiltInRegistries.ITEM.getValue(identifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
97
src/main/java/de/jottyfan/minecraft/name/ID.java
Normal file
97
src/main/java/de/jottyfan/minecraft/name/ID.java
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
package de.jottyfan.minecraft.name;
|
||||||
|
|
||||||
|
import de.jottyfan.minecraft.Quickly;
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jotty
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ID {
|
||||||
|
// items
|
||||||
|
public static final Identifier STUB = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "stub");
|
||||||
|
public static final Identifier RAWTURQUOISE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "rawturquoise");
|
||||||
|
public static final Identifier TURQUOISEINGOT = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "turquoiseingot");
|
||||||
|
public static final Identifier COTTON = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "cotton");
|
||||||
|
public static final Identifier COTTONPLANT = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "cottonplant");
|
||||||
|
public static final Identifier COTTONSEED = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "cottonseed");
|
||||||
|
public static final Identifier CANOLA = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "canola");
|
||||||
|
public static final Identifier CANOLAPLANT = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "canolaplant");
|
||||||
|
public static final Identifier CANOLASEED = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "canolaseed");
|
||||||
|
public static final Identifier CANOLABOTTLE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "canolabottle");
|
||||||
|
public static final Identifier CANOLABOTTLESTACK = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"canolabottlestack");
|
||||||
|
public static final Identifier ROTTEN_FLESH_STRIPES = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"rotten_flesh_stripes");
|
||||||
|
public static final Identifier OXIDIZEDCOPPERPOWDER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"oxidizedcopperpowder");
|
||||||
|
public static final Identifier COPPERSTRING = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "copperstring");
|
||||||
|
public static final Identifier COPPERPOWDER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "copperpowder");
|
||||||
|
public static final Identifier COPPERSTUB = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "copperstub");
|
||||||
|
public static final Identifier COPPERSTICK = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "copperstick");
|
||||||
|
public static final Identifier SPEEDPOWDER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "speedpowder");
|
||||||
|
public static final Identifier QUICKIEPOWDER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "quickiepowder");
|
||||||
|
public static final Identifier SPEEDINGOT = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "speedingot");
|
||||||
|
public static final Identifier QUICKIEINGOT = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "quickieingot");
|
||||||
|
public static final Identifier MAGNIFIER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "magnifier");
|
||||||
|
public static final Identifier SALPETER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "salpeter");
|
||||||
|
public static final Identifier SULFOR = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "sulfor");
|
||||||
|
public static final Identifier CARROTSTACK = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "carrotstack");
|
||||||
|
public static final Identifier SPEEDPOWDERAXE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "speedpowderaxe");
|
||||||
|
public static final Identifier SPEEDPOWDERHOE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "speedpowderhoe");
|
||||||
|
public static final Identifier SPEEDPOWDERPICKAXE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"speedpowderpickaxe");
|
||||||
|
public static final Identifier SPEEDPOWDERSHEARS = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"speedpowdershears");
|
||||||
|
public static final Identifier SPEEDPOWDERSHOVEL = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"speedpowdershovel");
|
||||||
|
public static final Identifier SPEEDPOWDERWATERHOE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"speedpowderwaterhoe");
|
||||||
|
public static final Identifier QUICKIEPOWDERAXE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "quickiepowderaxe");
|
||||||
|
public static final Identifier QUICKIEPOWDERHOE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "quickiepowderhoe");
|
||||||
|
public static final Identifier QUICKIEPOWDERPICKAXE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"quickiepowderpickaxe");
|
||||||
|
public static final Identifier QUICKIEPOWDERSHEARS = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"quickiepowdershears");
|
||||||
|
public static final Identifier QUICKIEPOWDERSHOVEL = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"quickiepowdershovel");
|
||||||
|
public static final Identifier QUICKIEPOWDERWATERHOE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"quickiepowderwaterhoe");
|
||||||
|
public static final Identifier TURQUOISE_BOOTS = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "turquoise_boots");
|
||||||
|
public static final Identifier TURQUOISE_HELMET = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "turquoise_helmet");
|
||||||
|
public static final Identifier TURQUOISE_LEGGINGS = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"turquoise_leggings");
|
||||||
|
public static final Identifier TURQUOISE_CHESTPLATE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"turquoise_chestplate");
|
||||||
|
|
||||||
|
// blocks
|
||||||
|
public static final Identifier KELPBUNDLE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "kelpbundle");
|
||||||
|
public static final Identifier BLOCKTURQUOISE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "blockturquoise");
|
||||||
|
public static final Identifier ORETURQUOISE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "oreturquoise");
|
||||||
|
public static final Identifier OREDEEPSLATETURQUOISE = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"oredeepslateturquoise");
|
||||||
|
public static final Identifier BLOCKCOTTONPLANT = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "blockcottonplant");
|
||||||
|
public static final Identifier BLOCKCANOLAPLANT = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "blockcanolaplant");
|
||||||
|
public static final Identifier LAVAHOARDER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "lavahoarder");
|
||||||
|
public static final Identifier BLOCKQUICKIEPOWDER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"blockquickiepowder");
|
||||||
|
public static final Identifier BLOCKSPEEDPOWDER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "blockspeedpowder");
|
||||||
|
public static final Identifier MONSTERHOARDER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "monsterhoarder");
|
||||||
|
public static final Identifier ITEMHOARDER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "itemhoarder");
|
||||||
|
public static final Identifier DRILL = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "drill");
|
||||||
|
public static final Identifier BLOCKSTACKER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "blockstacker");
|
||||||
|
public static final Identifier DIRTSALPETER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "dirtsalpeter");
|
||||||
|
public static final Identifier SANDSALPETER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "sandsalpeter");
|
||||||
|
public static final Identifier OREDEEPSLATESULFOR = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"oredeepslatesulfor");
|
||||||
|
public static final Identifier ORENETHERSULFOR = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "orenethersulfor");
|
||||||
|
public static final Identifier ORESALPETER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "oresalpeter");
|
||||||
|
public static final Identifier ORESANDSALPETER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "oresandsalpeter");
|
||||||
|
public static final Identifier ORESULFOR = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "oresulfor");
|
||||||
|
public static final Identifier ORESPEEDPOWDER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "orespeedpowder");
|
||||||
|
public static final Identifier OREDEEPSLATESPEEDPOWDER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID,
|
||||||
|
"oredeepslatespeedpowder");
|
||||||
|
public static final Identifier BLOCKSALPETER = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "blocksalpeter");
|
||||||
|
public static final Identifier BLOCKSULFOR = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "blocksulfor");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user