Skip to content

Commit

Permalink
Recipes, Tweaks/Fixes, More Organization (TM)
Browse files Browse the repository at this point in the history
  • Loading branch information
crispytwig committed Dec 11, 2024
1 parent ef4aa25 commit 5b242be
Show file tree
Hide file tree
Showing 105 changed files with 2,259 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LayeredCauldronBlock;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
Expand Down Expand Up @@ -77,6 +79,16 @@ public static double dyeHeight() {
return 1;
}

@Override
public @NotNull BlockState rotate(BlockState blockState, Rotation rotation) {
return blockState.setValue(FACING, rotation.rotate(blockState.getValue(FACING)));
}

@Override
public @NotNull BlockState mirror(BlockState blockState, Mirror mirror) {
return blockState.rotate(mirror.getRotation(blockState.getValue(FACING)));
}

public enum WreathGarland implements StringRepresentable {
EMPTY("empty"),
MULTICOLOR_LIGHTS("multicolor_lights"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.starfish_studios.seasons_greetings.crafting;

import com.starfish_studios.seasons_greetings.block.GiftBoxBlock;
import net.minecraft.core.HolderLookup;
import net.minecraft.world.item.DyeItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.CraftingBookCategory;
import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.CustomRecipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.NotNull;

public class GiftBoxColoring extends CustomRecipe {
public GiftBoxColoring(CraftingBookCategory craftingBookCategory) {
super(craftingBookCategory);
}

public boolean matches(CraftingInput craftingInput, Level level) {
int i = 0;
int j = 0;

for(int k = 0; k < craftingInput.size(); ++k) {
ItemStack itemStack = craftingInput.getItem(k);
if (!itemStack.isEmpty()) {
if (Block.byItem(itemStack.getItem()) instanceof GiftBoxBlock) {
++i;
} else {
if (!(itemStack.getItem() instanceof DyeItem)) {
return false;
}

++j;
}

if (j > 1 || i > 1) {
return false;
}
}
}

return i == 1 && j == 1;
}

public @NotNull ItemStack assemble(CraftingInput craftingInput, HolderLookup.Provider provider) {
ItemStack itemStack = ItemStack.EMPTY;
DyeItem dyeItem = (DyeItem) Items.WHITE_DYE;

for(int i = 0; i < craftingInput.size(); ++i) {
ItemStack itemStack2 = craftingInput.getItem(i);
if (!itemStack2.isEmpty()) {
Item item = itemStack2.getItem();
if (Block.byItem(item) instanceof GiftBoxBlock) {
itemStack = itemStack2;
} else if (item instanceof DyeItem) {
dyeItem = (DyeItem)item;
}
}
}

Block block = GiftBoxBlock.getBlockByColor(dyeItem.getDyeColor());
return itemStack.transmuteCopy(block, 1);
}

public boolean canCraftInDimensions(int i, int j) {
return i * j >= 2;
}

public @NotNull RecipeSerializer<?> getSerializer() {
return SGRecipeSerializer.GIFT_BOX_COLORING;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.starfish_studios.seasons_greetings.crafting;

import com.starfish_studios.seasons_greetings.SeasonsGreetings;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.SimpleCraftingRecipeSerializer;

public interface SGRecipeSerializer {
SimpleCraftingRecipeSerializer<GiftBoxColoring> GIFT_BOX_COLORING = register("gift_box_coloring", new SimpleCraftingRecipeSerializer<>(GiftBoxColoring::new));

static void registerCustomRecipes() {
}

static <S extends RecipeSerializer<T>, T extends Recipe<?>> S register(String string, S recipeSerializer) {
return Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, SeasonsGreetings.id(string), recipeSerializer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private PlayState attackPredicate(AnimationState<?> event) {
}

private <E extends GingerbreadMan> PlayState predicate(final AnimationState<E> event) {
if (this.isOrderedToSit()) {
if (this.isInSittingPose()) {
event.setAnimation(SIT);
} else if (event.isMoving()) {
if (this.getMainHandItem().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ public InteractionResult interact(Player player, Level level, InteractionHand ha


private InteractionResult handleShearsInteraction(Level level, BlockPos pos, BlockState blockState, Player player, InteractionHand hand) {
if (blockState.getValue(WreathBlock.BELL)) {
level.setBlockAndUpdate(pos, blockState.setValue(WreathBlock.BELL, false));
dropItem(level, pos, new ItemStack(Items.BELL));
shearDamageSound(level, pos, player, hand);
return InteractionResult.SUCCESS;
}

if (blockState.getValue(WreathBlock.BOW) != WreathBlock.WreathBowColors.EMPTY) {
WreathBlock.WreathBowColors bowColor = blockState.getValue(WreathBlock.BOW);
Item bowItem = SHEAR_MAP.get(bowColor);
Expand All @@ -122,6 +115,13 @@ private InteractionResult handleShearsInteraction(Level level, BlockPos pos, Blo
}
}

if (blockState.getValue(WreathBlock.BELL)) {
level.setBlockAndUpdate(pos, blockState.setValue(WreathBlock.BELL, false));
dropItem(level, pos, new ItemStack(Items.BELL));
shearDamageSound(level, pos, player, hand);
return InteractionResult.SUCCESS;
}

if (blockState.getValue(WreathBlock.GARLAND) != WreathBlock.WreathGarland.EMPTY) {
WreathBlock.WreathGarland garland = blockState.getValue(WreathBlock.GARLAND);
Item garlandItem = GARLAND_SHEAR_MAP.get(garland);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;

public class GiftBoxMenu extends AbstractContainerMenu {
private static final int SLOT_COUNT = 5;
private final Container mailbox;
private final Container gitBox;

public GiftBoxMenu(int i, Inventory inventory) {
this(i, inventory, new SimpleContainer(5));
}


public Container getContainer() {
return this.mailbox;
return this.gitBox;
}

public GiftBoxMenu(int i, Inventory inventory, Container container) {
super(SGMenus.GIFT_BOX, i);
checkContainerSize(container, 5);
this.mailbox = container;
this.gitBox = container;
container.startOpen(inventory.player);
int j;
int k;
for(j = 0; j < 1; ++j) {
for(k = 0; k < 5; ++k) {
this.addSlot(new Slot(container, k + j * 5, 44 + k * 18, 35 + j * 18));
this.addSlot(new GiftBoxSlot(container, k + j * 5, 44 + k * 18, 35 + j * 18));
}
}

Expand All @@ -48,10 +48,10 @@ public GiftBoxMenu(int i, Inventory inventory, Container container) {
}

public boolean stillValid(Player player) {
return this.mailbox.stillValid(player);
return this.gitBox.stillValid(player);
}

public ItemStack quickMoveStack(Player player, int i) {
public @NotNull ItemStack quickMoveStack(Player player, int i) {
ItemStack itemStack = ItemStack.EMPTY;
Slot slot = this.slots.get(i);
if (slot.hasItem()) {
Expand Down Expand Up @@ -83,6 +83,6 @@ public ItemStack quickMoveStack(Player player, int i) {

public void removed(Player player) {
super.removed(player);
this.mailbox.stopOpen(player);
this.gitBox.stopOpen(player);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.starfish_studios.seasons_greetings.inventory;

import net.minecraft.world.Container;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;

public class GiftBoxSlot extends Slot {
public GiftBoxSlot(Container container, int i, int j, int k) {
super(container, i, j, k);
}

public boolean mayPlace(ItemStack itemStack) {
return itemStack.getItem().canFitInsideContainerItems();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public GiftBoxItem(Block block, Properties properties) {
super(block, properties);
}

@Override
public boolean canFitInsideContainerItems() {
return false;
}

@Override
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltip, TooltipFlag flag) {
if (stack.has(DataComponents.BASE_COLOR)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import java.util.Objects;

public class GingerbreadCookieItem extends Item {
public GingerbreadCookieItem(Properties properties) {
public class GingerbreadManItem extends Item {
public GingerbreadManItem(Properties properties) {
super(properties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class SGCreativeTabs {
@SuppressWarnings("unused")
public static final CreativeModeTab SEASONS_GREETINGS_TAB = register("item_group", FabricItemGroup.builder().icon(FRUITCAKE::getDefaultInstance).title(Component.translatable("itemGroup.seasonsgreetings.tab")).displayItems((featureFlagSet, output) -> {
ItemStack stack = new ItemStack(CHRISTMAS_HAT);
stack.set(DataComponents.DYED_COLOR, new DyedItemColor(0xFF0000, true));
stack.set(DataComponents.DYED_COLOR, new DyedItemColor(0xA06540, false));

output.accept(stack);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import com.starfish_studios.seasons_greetings.SeasonsGreetings;
import com.starfish_studios.seasons_greetings.item.*;
import net.minecraft.core.Registry;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.*;
import net.minecraft.world.item.component.ItemContainerContents;

public class SGItems {
public static final Item CHRISTMAS_HAT = registerItem("christmas_hat", new ChristmasHatItem(ArmorMaterials.LEATHER, ArmorItem.Type.HELMET, new Item.Properties()));
Expand All @@ -14,12 +16,14 @@ public class SGItems {

public static final Item FRUITCAKE = registerItem("fruitcake", new Item(new Item.Properties()));

public static final Item GINGERBREAD_COOKIE = registerItem("gingerbread_cookie", new GingerbreadCookieItem(new Item.Properties()
public static final Item GINGERBREAD_COOKIE = registerItem("gingerbread_cookie", new Item(new Item.Properties()
.food(new FoodProperties.Builder()
.nutrition(2)
.saturationModifier(0.1f)
.build())));

public static final Item GINGERBREAD_MAN = registerItem("gingerbread_man", new GingerbreadManItem(new Item.Properties()));

public static final Item GINGERBREAD_CRUMBS = registerItem("gingerbread_crumbs", new Item(new Item.Properties()
.food(new FoodProperties.Builder()
.nutrition(1)
Expand Down Expand Up @@ -68,22 +72,24 @@ public class SGItems {

// region Gifts

public static final Item WHITE_GIFT_BOX = registerItem("white_gift_box", new GiftBoxItem(SGBlocks.WHITE_GIFT_BOX, new Item.Properties()));
public static final Item LIGHT_GRAY_GIFT_BOX = registerItem("light_gray_gift_box", new GiftBoxItem(SGBlocks.LIGHT_GRAY_GIFT_BOX, new Item.Properties()));
public static final Item GRAY_GIFT_BOX = registerItem("gray_gift_box", new GiftBoxItem(SGBlocks.GRAY_GIFT_BOX, new Item.Properties()));
public static final Item BLACK_GIFT_BOX = registerItem("black_gift_box", new GiftBoxItem(SGBlocks.BLACK_GIFT_BOX, new Item.Properties()));
public static final Item BROWN_GIFT_BOX = registerItem("brown_gift_box", new GiftBoxItem(SGBlocks.BROWN_GIFT_BOX, new Item.Properties()));
public static final Item RED_GIFT_BOX = registerItem("red_gift_box", new GiftBoxItem(SGBlocks.RED_GIFT_BOX, new Item.Properties()));
public static final Item ORANGE_GIFT_BOX = registerItem("orange_gift_box", new GiftBoxItem(SGBlocks.ORANGE_GIFT_BOX, new Item.Properties()));
public static final Item YELLOW_GIFT_BOX = registerItem("yellow_gift_box", new GiftBoxItem(SGBlocks.YELLOW_GIFT_BOX, new Item.Properties()));
public static final Item LIME_GIFT_BOX = registerItem("lime_gift_box", new GiftBoxItem(SGBlocks.LIME_GIFT_BOX, new Item.Properties()));
public static final Item GREEN_GIFT_BOX = registerItem("green_gift_box", new GiftBoxItem(SGBlocks.GREEN_GIFT_BOX, new Item.Properties()));
public static final Item CYAN_GIFT_BOX = registerItem("cyan_gift_box", new GiftBoxItem(SGBlocks.CYAN_GIFT_BOX, new Item.Properties()));
public static final Item LIGHT_BLUE_GIFT_BOX = registerItem("light_blue_gift_box", new GiftBoxItem(SGBlocks.LIGHT_BLUE_GIFT_BOX, new Item.Properties()));
public static final Item BLUE_GIFT_BOX = registerItem("blue_gift_box", new GiftBoxItem(SGBlocks.BLUE_GIFT_BOX, new Item.Properties()));
public static final Item PURPLE_GIFT_BOX = registerItem("purple_gift_box", new GiftBoxItem(SGBlocks.PURPLE_GIFT_BOX, new Item.Properties()));
public static final Item MAGENTA_GIFT_BOX = registerItem("magenta_gift_box", new GiftBoxItem(SGBlocks.MAGENTA_GIFT_BOX, new Item.Properties()));
public static final Item PINK_GIFT_BOX = registerItem("pink_gift_box", new GiftBoxItem(SGBlocks.PINK_GIFT_BOX, new Item.Properties()));
public static final Item.Properties giftBoxProperties = new Item.Properties().stacksTo(1).component(DataComponents.CONTAINER, ItemContainerContents.EMPTY);

public static final Item WHITE_GIFT_BOX = registerItem("white_gift_box", new GiftBoxItem(SGBlocks.WHITE_GIFT_BOX, giftBoxProperties));
public static final Item LIGHT_GRAY_GIFT_BOX = registerItem("light_gray_gift_box", new GiftBoxItem(SGBlocks.LIGHT_GRAY_GIFT_BOX, giftBoxProperties));
public static final Item GRAY_GIFT_BOX = registerItem("gray_gift_box", new GiftBoxItem(SGBlocks.GRAY_GIFT_BOX, giftBoxProperties));
public static final Item BLACK_GIFT_BOX = registerItem("black_gift_box", new GiftBoxItem(SGBlocks.BLACK_GIFT_BOX, giftBoxProperties));
public static final Item BROWN_GIFT_BOX = registerItem("brown_gift_box", new GiftBoxItem(SGBlocks.BROWN_GIFT_BOX, giftBoxProperties));
public static final Item RED_GIFT_BOX = registerItem("red_gift_box", new GiftBoxItem(SGBlocks.RED_GIFT_BOX, giftBoxProperties));
public static final Item ORANGE_GIFT_BOX = registerItem("orange_gift_box", new GiftBoxItem(SGBlocks.ORANGE_GIFT_BOX, giftBoxProperties));
public static final Item YELLOW_GIFT_BOX = registerItem("yellow_gift_box", new GiftBoxItem(SGBlocks.YELLOW_GIFT_BOX, giftBoxProperties));
public static final Item LIME_GIFT_BOX = registerItem("lime_gift_box", new GiftBoxItem(SGBlocks.LIME_GIFT_BOX, giftBoxProperties));
public static final Item GREEN_GIFT_BOX = registerItem("green_gift_box", new GiftBoxItem(SGBlocks.GREEN_GIFT_BOX, giftBoxProperties));
public static final Item CYAN_GIFT_BOX = registerItem("cyan_gift_box", new GiftBoxItem(SGBlocks.CYAN_GIFT_BOX, giftBoxProperties));
public static final Item LIGHT_BLUE_GIFT_BOX = registerItem("light_blue_gift_box", new GiftBoxItem(SGBlocks.LIGHT_BLUE_GIFT_BOX, giftBoxProperties));
public static final Item BLUE_GIFT_BOX = registerItem("blue_gift_box", new GiftBoxItem(SGBlocks.BLUE_GIFT_BOX, giftBoxProperties));
public static final Item PURPLE_GIFT_BOX = registerItem("purple_gift_box", new GiftBoxItem(SGBlocks.PURPLE_GIFT_BOX, giftBoxProperties));
public static final Item MAGENTA_GIFT_BOX = registerItem("magenta_gift_box", new GiftBoxItem(SGBlocks.MAGENTA_GIFT_BOX, giftBoxProperties));
public static final Item PINK_GIFT_BOX = registerItem("pink_gift_box", new GiftBoxItem(SGBlocks.PINK_GIFT_BOX, giftBoxProperties));

// endregion

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.starfish_studios.seasons_greetings.registry;

import com.starfish_studios.seasons_greetings.crafting.SGRecipeSerializer;

public class SGRegistry {

public static void registerAll() {
// SeasonsGreetingsEntityType.registerEntities();
SGRecipeSerializer.registerCustomRecipes();
SGEffects.registerEffects();
SGParticles.registerParticles();
SGBlockEntityType.registerBlockEntities();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_item": {
"conditions": {
"items": [
{
"items": "minecraft:snowball"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_recipe": {
"conditions": {
"recipe": "seasonsgreetings:chiseled_snow"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_recipe",
"has_item"
]
],
"rewards": {
"recipes": [
"seasonsgreetings:chiseled_snow"
]
}
}
Loading

0 comments on commit 5b242be

Please sign in to comment.