Compare commits
16 Commits
0b9db5fd0e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d251b27e9 | ||
|
|
d888283838 | ||
|
|
5bc14bb222 | ||
|
|
a71c23cf28 | ||
|
|
732c8fd3d2 | ||
|
|
96ee5749c9 | ||
|
|
8dc3145493 | ||
|
|
ea72b9c7f0 | ||
|
|
7c531cdbef | ||
|
|
8e2eb70524 | ||
|
|
c0c70ecfce | ||
|
|
57ed5584cb | ||
|
|
49820490b6 | ||
|
|
489af3ef92 | ||
|
|
595901802c | ||
|
|
ef0a496cc7 |
2
.settings/org.eclipse.core.resources.prefs
Normal file
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
@@ -7,14 +7,14 @@ org.gradle.configuration-cache=false
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=26.1-snapshot-3
|
||||
minecraft_version=26.1-pre-1
|
||||
loader_version=0.18.4
|
||||
loom_version=1.14-SNAPSHOT
|
||||
loom_version=1.15-SNAPSHOT
|
||||
|
||||
# Mod Properties
|
||||
mod_version=26.1.2
|
||||
mod_version=26.1-pre-1
|
||||
maven_group=de.jottyfan.minecraft
|
||||
archives_base_name=quickly
|
||||
|
||||
# Dependencies
|
||||
fabric_api_version=0.141.3+26.1
|
||||
fabric_api_version=0.143.12+26.1
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.jottyfan.minecraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -10,7 +12,10 @@ import de.jottyfan.minecraft.event.QuicklyEvents;
|
||||
import de.jottyfan.minecraft.feature.QuicklyFeatures;
|
||||
import de.jottyfan.minecraft.item.QuicklyItems;
|
||||
import de.jottyfan.minecraft.loot.QuicklyLootTables;
|
||||
import de.jottyfan.minecraft.tab.QuicklyTab;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
@@ -25,11 +30,12 @@ public class Quickly implements ModInitializer {
|
||||
public void onInitialize() {
|
||||
LOGGER.info("loading {}", MOD_ID);
|
||||
|
||||
QuicklyItems.registerModItems();
|
||||
QuicklyBlocks.registerModBlocks();
|
||||
List<Item> items = QuicklyItems.registerModItems();
|
||||
List<Block> blocks = QuicklyBlocks.registerModBlocks();
|
||||
QuicklyBlockEntity.registerBlockEntities();
|
||||
QuicklyFeatures.registerFeatures();
|
||||
QuicklyComposter.registerComposterItems();
|
||||
QuicklyTab.registerItemGroup(items, blocks);
|
||||
QuicklyLootTables.registerChanges();
|
||||
QuicklyEvents.registerBlockBreak();
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ public class BlockDrill extends FallingBlock implements EntityBlock {
|
||||
loadings.put(QuicklyItems.CANOLABOTTLESTACK, 72);
|
||||
Item item = itemStack.getItem();
|
||||
if (QuicklyItems.MAGNIFIER.equals(item)) {
|
||||
if (!level.isClientSide() && player instanceof ServerPlayer serverPlayer) {
|
||||
serverPlayer.displayClientMessage(Component.translatable("info.block.drillfuel", state.getValue(FUEL)), true);
|
||||
if (!level.isClientSide() && player instanceof ServerPlayer serverPlayer && player != null) {
|
||||
serverPlayer.connection.player.sendSystemMessage(Component.translatable("info.block.drillfuel", state.getValue(FUEL)), true);
|
||||
}
|
||||
} else if (loadings.containsKey(item)) {
|
||||
Integer fuelWeight = loadings.get(item);
|
||||
|
||||
@@ -2,16 +2,19 @@ package de.jottyfan.minecraft.block;
|
||||
|
||||
import de.jottyfan.minecraft.item.QuicklyItems;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.CropBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -20,21 +23,36 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||
*/
|
||||
public class BlockPlant extends CropBlock {
|
||||
|
||||
private Identifier seedName;
|
||||
private Identifier fruitName;
|
||||
private DropDefinition seedDefinition;
|
||||
private DropDefinition fruitDefinition;
|
||||
|
||||
public BlockPlant(Properties properties, Identifier seedName, Identifier fruitName) {
|
||||
super(properties);
|
||||
this.seedName = seedName;
|
||||
this.fruitName = fruitName;
|
||||
public BlockPlant(Properties properties, DropDefinition seedDefinition, DropDefinition fruitDefinition) {
|
||||
super(properties.noOcclusion().dynamicShape());
|
||||
this.seedDefinition = seedDefinition;
|
||||
this.fruitDefinition = fruitDefinition;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
|
||||
return Block.box(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getShadeBrightness(BlockState state, BlockGetter level, BlockPos pos) {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean propagatesSkylightDown(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemLike getSeed() {
|
||||
return QuicklyItems.of(seedName);
|
||||
return QuicklyItems.of(seedDefinition.getIdentifier());
|
||||
}
|
||||
|
||||
public ItemLike getFruit() {
|
||||
return QuicklyItems.of(fruitName);
|
||||
return QuicklyItems.of(fruitDefinition.getIdentifier());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package de.jottyfan.minecraft.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
@@ -7,6 +10,7 @@ import com.mojang.serialization.MapCodec;
|
||||
import de.jottyfan.minecraft.blockentity.BlockStackerEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -15,8 +19,9 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.storage.loot.LootParams.Builder;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -37,13 +42,21 @@ public class BlockStacker extends Block implements EntityBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(SOURCE, DEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ItemStack> getDrops(BlockState state, Builder params) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuicklyBlocks.STACKER));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return this.defaultBlockState().setValue(SOURCE, context.getNearestLookingDirection()).setValue(DEST, context.getNearestLookingDirection().getOpposite());
|
||||
return this.defaultBlockState().setValue(SOURCE, context.getNearestLookingDirection()).setValue(DEST,
|
||||
context.getNearestLookingDirection().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package de.jottyfan.minecraft.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.resources.Identifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class DropDefinition {
|
||||
private Identifier identifier;
|
||||
private Integer minValue;
|
||||
private Integer maxValue;
|
||||
|
||||
/**
|
||||
* defines the drop definition; the item or block from identifier should be
|
||||
* dropped x times (minValue <= x <= maxValue)
|
||||
*
|
||||
* @param identifier the identifier of the item or block
|
||||
* @param minValue the minimum of dropped items or blocks
|
||||
* @param maxValue the maximum of dropped items or blocks
|
||||
*/
|
||||
public static final DropDefinition of(Identifier identifier, Integer minValue, Integer maxValue) {
|
||||
DropDefinition bean = new DropDefinition();
|
||||
bean.setIdentifier(identifier);
|
||||
bean.setMinValue(minValue);
|
||||
bean.setMaxValue(maxValue);
|
||||
return bean;
|
||||
}
|
||||
|
||||
public int getRandomSize() {
|
||||
if (maxValue - minValue < 1) {
|
||||
return new Random().nextInt(maxValue);
|
||||
} else {
|
||||
return minValue + new Random().nextInt(maxValue - minValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the identifier
|
||||
*/
|
||||
public Identifier getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param identifier the identifier to set
|
||||
*/
|
||||
public void setIdentifier(Identifier identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minValue
|
||||
*/
|
||||
public Integer getMinValue() {
|
||||
return minValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param minValue the minValue to set
|
||||
*/
|
||||
public void setMinValue(Integer minValue) {
|
||||
this.minValue = minValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maxValue
|
||||
*/
|
||||
public Integer getMaxValue() {
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxValue the maxValue to set
|
||||
*/
|
||||
public void setMaxValue(Integer maxValue) {
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class Itemhoarder extends Block implements EntityBlock {
|
||||
@Override
|
||||
protected InteractionResult useItemOn(ItemStack itemStack, BlockState state, Level level, BlockPos pos, Player player,
|
||||
InteractionHand hand, BlockHitResult hitResult) {
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
if (player instanceof ServerPlayer serverPlayer && player != null) {
|
||||
if (QuicklyItems.MAGNIFIER.equals(itemStack.getItem())) {
|
||||
MutableComponent message = Component.empty();
|
||||
BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
@@ -68,7 +68,7 @@ public class Itemhoarder extends Block implements EntityBlock {
|
||||
}
|
||||
}
|
||||
Component complete = Component.translatable("info.block.itemhoarder", message);
|
||||
serverPlayer.displayClientMessage(complete, false);
|
||||
serverPlayer.connection.player.sendSystemMessage(complete, false);
|
||||
}
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package de.jottyfan.minecraft.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import de.jottyfan.minecraft.item.QuicklyItems;
|
||||
@@ -20,8 +23,9 @@ import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.storage.loot.LootParams.Builder;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.ticks.ScheduledTick;
|
||||
@@ -46,10 +50,17 @@ public class Monsterhoarder extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(SUCKRADIUS, BURNTICKS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ItemStack> getDrops(BlockState state, Builder params) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
list.add(new ItemStack(QuicklyBlocks.MONSTERHOARDER));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InteractionResult useItemOn(ItemStack itemStack, BlockState state, Level level, BlockPos pos, Player player,
|
||||
InteractionHand hand, BlockHitResult hitResult) {
|
||||
@@ -73,8 +84,8 @@ public class Monsterhoarder extends Block {
|
||||
int suckRadius = state.getValue(SUCKRADIUS);
|
||||
int burnTicks = state.getValue(BURNTICKS);
|
||||
Component message = Component.translatable("info.block.monsterhoarder", suckRadius, burnTicks);
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
serverPlayer.displayClientMessage(message, true);
|
||||
if (player instanceof ServerPlayer serverPlayer && player != null) {
|
||||
serverPlayer.connection.player.sendSystemMessage(message, true);
|
||||
}
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.jottyfan.minecraft.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import de.jottyfan.minecraft.Quickly;
|
||||
@@ -32,9 +34,11 @@ public class QuicklyBlocks {
|
||||
public static final Block OREDEEPSLATETURQUOISE = registerBlock(ID.OREDEEPSLATETURQUOISE,
|
||||
properties -> new BlockOre(properties, SoundEvents.AMETHYST_BLOCK_CHIME, ID.RAWTURQUOISE));
|
||||
public static final Block COTTONPLANT = registerBlock(ID.BLOCKCOTTONPLANT, Properties.ofFullCopy(Blocks.WHEAT),
|
||||
properties -> new BlockPlant(properties, ID.COTTONSEED, ID.COTTON));
|
||||
properties -> new BlockPlant(properties, DropDefinition.of(ID.COTTONSEED, 1, 1),
|
||||
DropDefinition.of(ID.COTTON, 1, 1)));
|
||||
public static final Block CANOLAPLANT = registerBlock(ID.BLOCKCANOLAPLANT, Properties.ofFullCopy(Blocks.WHEAT),
|
||||
properties -> new BlockPlant(properties, ID.CANOLASEED, ID.CANOLA));
|
||||
properties -> new BlockPlant(properties, DropDefinition.of(ID.CANOLASEED, 1, 1),
|
||||
DropDefinition.of(ID.CANOLA, 1, 1)));
|
||||
public static final Block LAVAHOARDER = registerBlock(ID.LAVAHOARDER,
|
||||
Properties.of().strength(2.5f).lightLevel(state -> state.getValue(Lavahoarder.FILLED) ? 15 : 0),
|
||||
Lavahoarder::new);
|
||||
@@ -98,7 +102,31 @@ public class QuicklyBlocks {
|
||||
return BuiltInRegistries.BLOCK.getValue(identifier);
|
||||
}
|
||||
|
||||
public static void registerModBlocks() {
|
||||
Quickly.LOGGER.info("forbid the optimizer to ignore static block registration");
|
||||
public static final List<Block> registerModBlocks() {
|
||||
Quickly.LOGGER.debug("register blocks");
|
||||
List<Block> set = new ArrayList<>();
|
||||
set.add(KELPBUNDLE);
|
||||
set.add(TURQUOISEBLOCK);
|
||||
set.add(ORETURQUOISE);
|
||||
set.add(OREDEEPSLATETURQUOISE);
|
||||
set.add(LAVAHOARDER);
|
||||
set.add(QUICKIEPOWDER);
|
||||
set.add(SPEEDPOWDER);
|
||||
set.add(MONSTERHOARDER);
|
||||
set.add(ITEMHOARDER);
|
||||
set.add(DRILL);
|
||||
set.add(STACKER);
|
||||
set.add(DIRTSALPETER);
|
||||
set.add(SANDSALPETER);
|
||||
set.add(OREDEEPSLATESULFOR);
|
||||
set.add(ORENETHERSULFOR);
|
||||
set.add(ORESALPETER);
|
||||
set.add(ORESANDSALPETER);
|
||||
set.add(ORESULFOR);
|
||||
set.add(ORESPEEDPOWDER);
|
||||
set.add(OREDEEPSLATESPEEDPOWDER);
|
||||
set.add(SALPETERBLOCK);
|
||||
set.add(SULFORBLOCK);
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,10 @@ import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.HoeItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -18,6 +20,8 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.CropBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
/**
|
||||
@@ -26,18 +30,19 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||
*
|
||||
*/
|
||||
public class QHoe extends HoeItem implements ToolRangeable {
|
||||
|
||||
public QIP 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);
|
||||
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
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
InteractionResult res = super.useOn(context);
|
||||
boolean isCrop = context.getLevel().getBlockState(context.getClickedPos()).getBlock() instanceof CropBlock;
|
||||
Block block = context.getLevel().getBlockState(context.getClickedPos()).getBlock();
|
||||
boolean isCrop = block instanceof CropBlock;
|
||||
if (!InteractionResult.PASS.equals(res) || isCrop) {
|
||||
HarvestRange range = properties.getHarvestRange();
|
||||
for (int x = -range.getxRange(); x <= range.getxRange(); x++) {
|
||||
@@ -55,6 +60,7 @@ public class QHoe extends HoeItem implements ToolRangeable {
|
||||
}
|
||||
}
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -69,16 +75,24 @@ public class QHoe extends HoeItem implements ToolRangeable {
|
||||
}
|
||||
|
||||
private void harvestIfPossible(BlockPos pos, Level level) {
|
||||
if (!level.isClientSide()) {
|
||||
BlockState blockState = level.getBlockState(pos);
|
||||
Block block = blockState.getBlock();
|
||||
if (block instanceof CropBlock) {
|
||||
CropBlock cBlock = (CropBlock) block;
|
||||
if (block instanceof CropBlock cBlock) {
|
||||
if (cBlock.isMaxAge(blockState)) {
|
||||
Block.dropResources(blockState, level, pos);
|
||||
LootParams.Builder builder = new LootParams.Builder((ServerLevel) level)
|
||||
.withParameter(LootContextParams.ORIGIN, pos.getCenter())
|
||||
.withParameter(LootContextParams.BLOCK_STATE, blockState)
|
||||
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, level.getBlockEntity(pos))
|
||||
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY);
|
||||
for (ItemStack stack : blockState.getDrops(builder)) {
|
||||
Containers.dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), stack);
|
||||
}
|
||||
level.setBlockAndUpdate(pos, cBlock.defaultBlockState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreakNeighbors(BlockState blockState) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.jottyfan.minecraft.item;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@@ -26,7 +27,7 @@ public class QShovel extends ShovelItem implements ToolRangeable {
|
||||
this.range = properties.getHarvestRange();
|
||||
}
|
||||
|
||||
private void createPathOnGrass(Level level, BlockPos pos, Direction side) {
|
||||
private void createPath(Level level, BlockPos pos, Direction side, Set<Block> validBlocks) {
|
||||
BlockState blockState = level.getBlockState(pos);
|
||||
if (blockState.isAir()) {
|
||||
// try to find one underneath
|
||||
@@ -39,18 +40,23 @@ public class QShovel extends ShovelItem implements ToolRangeable {
|
||||
if (side != Direction.DOWN) {
|
||||
if (blockState != null && level.getBlockState(pos.above()).isAir()) {
|
||||
if (!level.isClientSide()) {
|
||||
if (validBlocks.contains(blockState.getBlock())) {
|
||||
level.setBlockAndUpdate(pos, Blocks.DIRT_PATH.defaultBlockState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
InteractionResult result = super.useOn(context);
|
||||
if (InteractionResult.SUCCESS.equals(result)) {
|
||||
for (BlockPos pos : range.getRangeAsBlockPosArray(context.getClickedPos(), true, new BlockPos(1, 1, 1))) {
|
||||
createPathOnGrass(context.getLevel(), pos, context.getClickedFace());
|
||||
createPath(context.getLevel(), pos, context.getClickedFace(), FLATTENABLES.keySet());
|
||||
}
|
||||
return super.useOn(context);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.jottyfan.minecraft.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import de.jottyfan.minecraft.Quickly;
|
||||
@@ -44,6 +46,7 @@ public class QuicklyItems {
|
||||
public static final Item SALPETER = registerItem(ID.SALPETER);
|
||||
public static final Item SULFOR = registerItem(ID.SULFOR);
|
||||
public static final Item CARROTSTACK = registerItem(ID.CARROTSTACK);
|
||||
public static final Item POTATOSTACK = registerItem(ID.POTATOSTACK);
|
||||
|
||||
// TODO: rename tools to speedaxe and quickaxe instead of the powder version
|
||||
|
||||
@@ -97,8 +100,50 @@ public class QuicklyItems {
|
||||
return Registry.register(BuiltInRegistries.ITEM, identifier, item);
|
||||
}
|
||||
|
||||
public static final void registerModItems() {
|
||||
Quickly.LOGGER.info("forbid the optimizer to ignore static item registration");
|
||||
public static final List<Item> registerModItems() {
|
||||
Quickly.LOGGER.debug("adding Items");
|
||||
List<Item> set = new ArrayList<>();
|
||||
set.add(STUB);
|
||||
set.add(RAWTURQUOISE);
|
||||
set.add(TURQUOISEINGOT);
|
||||
set.add(COTTON);
|
||||
set.add(COTTONSEED);
|
||||
set.add(CANOLA);
|
||||
set.add(CANOLASEED);
|
||||
set.add(CANOLABOTTLE);
|
||||
set.add(CANOLABOTTLESTACK);
|
||||
set.add(ROTTENFLESHSTRIPES);
|
||||
set.add(OXIDIZEDCOPPERPOWDER);
|
||||
set.add(COPPERSTRING);
|
||||
set.add(COPPERPOWDER);
|
||||
set.add(COPPERSTUB);
|
||||
set.add(COPPERSTICK);
|
||||
set.add(SPEEDPOWDER);
|
||||
set.add(QUICKIEPOWDER);
|
||||
set.add(SPEEDINGOT);
|
||||
set.add(QUICKIEINGOT);
|
||||
set.add(MAGNIFIER);
|
||||
set.add(SALPETER);
|
||||
set.add(SULFOR);
|
||||
set.add(CARROTSTACK);
|
||||
set.add(POTATOSTACK);
|
||||
set.add(SPEEDAXE);
|
||||
set.add(SPEEDHOE);
|
||||
set.add(SPEEDPICKAXE);
|
||||
set.add(SPEEDSHEARS);
|
||||
set.add(SPEEDSHOVEL);
|
||||
set.add(SPEEDWATERHOE);
|
||||
set.add(QUICKIEAXE);
|
||||
set.add(QUICKIEHOE);
|
||||
set.add(QUICKIEPICKAXE);
|
||||
set.add(QUICKIESHEARS);
|
||||
set.add(QUICKIESHOVEL);
|
||||
set.add(QUICKIEWATERHOE);
|
||||
set.add(ARMOR_TURQUOISE_BOOTS);
|
||||
set.add(ARMOR_TURQUOISE_HELMET);
|
||||
set.add(ARMOR_TURQUOISE_LEGGINGS);
|
||||
set.add(ARMOR_TURQUOISE_CHESTPLATE);
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package de.jottyfan.minecraft.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class QuicklyMixin {
|
||||
@Inject(at = @At("HEAD"), method = "loadLevel")
|
||||
private void init(CallbackInfo info) {
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ public class ID {
|
||||
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 POTATOSTACK = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "potatostack");
|
||||
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,
|
||||
|
||||
42
src/main/java/de/jottyfan/minecraft/tab/QuicklyTab.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package de.jottyfan.minecraft.tab;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.jottyfan.minecraft.Quickly;
|
||||
import de.jottyfan.minecraft.item.QuicklyItems;
|
||||
import net.fabricmc.fabric.api.creativetab.v1.FabricCreativeModeTab;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class QuicklyTab {
|
||||
|
||||
public static final void registerItemGroup(List<Item> items, List<Block> blocks) {
|
||||
ResourceKey<CreativeModeTab> tabKey = ResourceKey.create(Registries.CREATIVE_MODE_TAB,
|
||||
Identifier.fromNamespaceAndPath(Quickly.MOD_ID, "itemgroup"));
|
||||
|
||||
CreativeModeTab quicklyTab = FabricCreativeModeTab.builder().icon(() -> new ItemStack(QuicklyItems.QUICKIEPICKAXE))
|
||||
.title(Component.translatable("tab.quickly")).displayItems((params, output) -> {
|
||||
for (Item item : items) {
|
||||
output.accept(item);
|
||||
}
|
||||
for (Block block : blocks) {
|
||||
output.accept(block);
|
||||
}
|
||||
}).build();
|
||||
|
||||
Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, tabKey, quicklyTab);
|
||||
}
|
||||
}
|
||||
6
src/main/resources/assets/quickly/items/potatostack.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "quickly:item/potatostack"
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@
|
||||
"item.quickly.oresulfor": "Schwefelgestein",
|
||||
"item.quickly.oreturquoise": "Türkiserz",
|
||||
"item.quickly.oxidizedcopperpowder": "oxidiertes Kupferpulver",
|
||||
"item.quickly.potatostack": "Kartoffelbündel",
|
||||
"item.quickly.quickieingot": "Eilpulverbarren",
|
||||
"item.quickly.quickiepowder": "Eilpulver",
|
||||
"item.quickly.quickiepowderaxe": "Eilaxt",
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
"item.quickly.oresulfor": "sulfor stone",
|
||||
"item.quickly.oreturquoise": "turquoise ore",
|
||||
"item.quickly.oxidizedcopperpowder": "oxidized copper powder",
|
||||
"item.quickly.potatostack": "potato bundle",
|
||||
"item.quickly.quickieingot": "quickie powder ingot",
|
||||
"item.quickly.quickiepowder": "quickie powder",
|
||||
"item.quickly.quickiepowderaxe": "hurry axe",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent": "minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/canolaplant0"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/canolaplant1"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/canolaplant2"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/canolaplant3"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/canolaplant4"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/canolaplant5"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/canolaplant6"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/canolaplant7"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/cottonplant0"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/cottonplant1"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/cottonplant2"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/cottonplant3"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/cottonplant4"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/cottonplant5"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/cottonplant6"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent":"block/cross",
|
||||
"parent":"minecraft:block/cross",
|
||||
"render_type": "minecraft:cutout",
|
||||
"textures":{
|
||||
"cross":"quickly:block/cottonplant7"
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "quickly:item/potatostack"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 255 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 324 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 403 B |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 463 B |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 513 B |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 527 B |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 645 B |
BIN
src/main/resources/assets/quickly/textures/item/potatostack.png
Normal file
|
After Width: | Height: | Size: 642 B |
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "quickly:canola",
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:set_count",
|
||||
"count": {
|
||||
"min": 1,
|
||||
"max": 2
|
||||
},
|
||||
"add": false
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:location_check",
|
||||
"predicate": {
|
||||
"block": {
|
||||
"properties": {
|
||||
"age": "7"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "quickly:canolaseed",
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:apply_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"formula": "minecraft:binomial_with_bonus_count",
|
||||
"parameters": {
|
||||
"extra": 2,
|
||||
"probability": 0.5
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "quickly:cotton",
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:set_count",
|
||||
"count": {
|
||||
"min": 1,
|
||||
"max": 3
|
||||
}
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:location_check",
|
||||
"predicate": {
|
||||
"block": {
|
||||
"properties": {
|
||||
"age": "7"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "quickly:cottonseed",
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:apply_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"formula": "minecraft:binomial_with_bonus_count",
|
||||
"parameters": {
|
||||
"extra": 2,
|
||||
"probability": 0.5
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"type": "crafting_shaped",
|
||||
"pattern": [
|
||||
"cc",
|
||||
"cc"
|
||||
],
|
||||
"key": {
|
||||
"c": "minecraft:potato"
|
||||
},
|
||||
"result": {
|
||||
"id": "quickly:potatostack"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
"quickly:potatostack"
|
||||
],
|
||||
"result": {
|
||||
"id": "minecraft:potato",
|
||||
"count": 4
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,6 @@
|
||||
"de.jottyfan.minecraft.QuicklyClient"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"quickly.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.18.4",
|
||||
"minecraft": "~26.1-",
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "de.jottyfan.minecraft.mixin",
|
||||
"compatibilityLevel": "JAVA_25",
|
||||
"mixins": [
|
||||
"QuicklyMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"overwrites": {
|
||||
"requireAnnotations": true
|
||||
}
|
||||
}
|
||||