Skip to content

Commit e9c89dd

Browse files
committed
feat: Just add a dummy interaction to the Coffee Machine for now, need to get an overview of what coffee mods exist in 26.1 before making an implementation
1 parent 9f9c674 commit e9c89dd

2 files changed

Lines changed: 39 additions & 13 deletions

File tree

common/src/main/java/net/blay09/mods/cookingforblockheads/block/CoffeeMachineBlock.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22

33
import com.mojang.serialization.MapCodec;
44
import net.minecraft.core.BlockPos;
5+
import net.minecraft.core.particles.ParticleTypes;
6+
import net.minecraft.server.level.ServerLevel;
7+
import net.minecraft.world.InteractionHand;
8+
import net.minecraft.world.InteractionResult;
9+
import net.minecraft.world.entity.player.Player;
10+
import net.minecraft.world.item.ItemStack;
511
import net.minecraft.world.level.BlockGetter;
12+
import net.minecraft.world.level.Level;
613
import net.minecraft.world.level.block.BaseEntityBlock;
714
import net.minecraft.world.level.block.Block;
815
import net.minecraft.world.level.block.entity.BlockEntity;
916
import net.minecraft.world.level.block.state.BlockState;
17+
import net.minecraft.world.phys.BlockHitResult;
1018
import net.minecraft.world.phys.shapes.CollisionContext;
1119
import net.minecraft.world.phys.shapes.VoxelShape;
1220
import org.jspecify.annotations.Nullable;
@@ -36,4 +44,17 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
3644
protected MapCodec<? extends BaseEntityBlock> codec() {
3745
return CODEC;
3846
}
47+
48+
@Override
49+
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
50+
if (level instanceof ServerLevel serverLevel) {
51+
serverLevel.sendParticles(ParticleTypes.HEART, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.25, 0, 0.25, 1);
52+
}
53+
return InteractionResult.SUCCESS;
54+
}
55+
56+
@Override
57+
protected InteractionResult useItemOn(ItemStack itemStack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
58+
return InteractionResult.TRY_WITH_EMPTY_HAND;
59+
}
3960
}

common/src/main/java/net/blay09/mods/cookingforblockheads/item/ModItems.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@
88
import net.minecraft.core.component.DataComponents;
99
import net.minecraft.network.chat.Component;
1010
import net.minecraft.resources.ResourceKey;
11+
import net.minecraft.sounds.SoundEvents;
1112
import net.minecraft.world.entity.EquipmentSlot;
1213
import net.minecraft.world.food.FoodProperties;
1314
import net.minecraft.world.item.DyeColor;
1415
import net.minecraft.world.item.Item;
1516
import net.minecraft.world.item.ItemStack;
1617
import net.minecraft.world.item.equipment.EquipmentAssets;
1718
import net.minecraft.world.item.equipment.Equippable;
18-
import net.minecraft.sounds.SoundEvents;
1919

2020
import java.util.Map;
2121

22+
import static net.blay09.mods.cookingforblockheads.CookingForBlockheads.id;
23+
2224
public class ModItems {
2325

2426
public static DeferredItem recipeBook;
@@ -38,25 +40,28 @@ public static void initialize(BalmItemRegistrar items) {
3840
heatingUnit = items.register("heating_unit", ItemHeatingUnit::new).asDeferredItem();
3941
iceUnit = items.register("ice_unit", ItemIceUnit::new).asDeferredItem();
4042
saltFilter = items.register("salt_filter", SaltFilterItem::new).asDeferredItem();
41-
iceCubes = items.register("ice_cubes", properties -> new Item(properties.stacksTo(16).food(new FoodProperties.Builder()
42-
.nutrition(0)
43-
.saturationModifier(0f)
44-
.alwaysEdible()
45-
.build()))).asDeferredItem();
43+
iceCubes = items.register("ice_cubes", Item::new, it -> it.stacksTo(16)
44+
.food(new FoodProperties.Builder()
45+
.nutrition(0)
46+
.saturationModifier(0f)
47+
.alwaysEdible()
48+
.build())
49+
).asDeferredItem();
4650
preservationChamber = items.register("preservation_chamber", ItemPreservationChamber::new).asDeferredItem();
47-
chefHat = items.register("chef_hat", properties -> new Item(properties.stacksTo(1).component(
48-
DataComponents.EQUIPPABLE,
49-
Equippable.builder(EquipmentSlot.HEAD)
50-
.setEquipSound(SoundEvents.ARMOR_EQUIP_LEATHER)
51-
.setAsset(ResourceKey.create(EquipmentAssets.ROOT_ID, CookingForBlockheads.id("chef_hat")))
52-
.build()))).asDeferredItem();
51+
chefHat = items.register("chef_hat", Item::new, it -> it.stacksTo(1)
52+
.component(DataComponents.EQUIPPABLE,
53+
Equippable.builder(EquipmentSlot.HEAD)
54+
.setEquipSound(SoundEvents.ARMOR_EQUIP_LEATHER)
55+
.setAsset(ResourceKey.create(EquipmentAssets.ROOT_ID, id("chef_hat")))
56+
.build())
57+
).asDeferredItem();
5358
}
5459

5560
public static void initialize(BalmCreativeModeTabRegistrar creativeModeTabs) {
5661
creativeModeTabs.register(CookingForBlockheads.MOD_ID, builder ->
5762
builder.title(Component.translatable("itemGroup.cookingforblockheads.cookingforblockheads"))
5863
.icon(() -> new ItemStack(ModBlocks.cowJar))
59-
.displayItems((parameters, output) -> {
64+
.displayItems((_, output) -> {
6065
output.accept(recipeBook);
6166
output.accept(craftingBook);
6267
output.accept(ModBlocks.cookingTables.get(null));

0 commit comments

Comments
 (0)