Skip to content

Commit

Permalink
Hot Cocoa, Warm Milk, Gingerbread house material bases, some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
crispytwig committed Dec 5, 2024
1 parent 84a6590 commit e204d80
Show file tree
Hide file tree
Showing 171 changed files with 4,020 additions and 74 deletions.
16 changes: 16 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,25 @@ base {
archivesName = project.archives_base_name
}


loom {
accessWidenerPath = file("src/main/resources/seasonsgreetings.accesswidener")
}

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {
name = 'GeckoLib'
url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
content {
includeGroupByRegex("software\\.bernie.*")
includeGroup("com.eliotlash.mclib")
}
}
}

dependencies {
Expand All @@ -26,6 +39,9 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation("software.bernie.geckolib:geckolib-fabric-${minecraft_version}:${geckolib_version}")
implementation("com.eliotlash.mclib:mclib:20")

}

Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ maven_group=com.starfish_studios
archives_base_name=seasonsgreetings

# Dependencies
fabric_version=0.110.0+1.21.1
fabric_version=0.110.0+1.21.1
geckolib_version=4.7
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.starfish_studios.seasons_greetings.block;

import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.BlockGetter;
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.phys.Vec3;

public class BouncyBlock extends Block {

public BouncyBlock(Properties properties) {
super(properties);
}

public void fallOn(Level level, BlockState blockState, BlockPos blockPos, Entity entity, float f) {
super.fallOn(level, blockState, blockPos, entity, f * 0.5F);
}

public void updateEntityAfterFallOn(BlockGetter blockGetter, Entity entity) {
if (entity.isSuppressingBounce()) {
super.updateEntityAfterFallOn(blockGetter, entity);
} else {
this.bounceUp(entity);
}
}

private void bounceUp(Entity entity) {
Vec3 vec3 = entity.getDeltaMovement();
if (vec3.y < 0.0) {
double d = entity instanceof LivingEntity ? 1.0 : 0.8;
entity.setDeltaMovement(vec3.x, -vec3.y * 0.6600000262260437 * d, vec3.z);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.starfish_studios.seasons_greetings.block;

import net.minecraft.world.level.block.DoorBlock;
import net.minecraft.world.level.block.state.properties.BlockSetType;

public class GingerbreadDoorBlock extends DoorBlock {
public GingerbreadDoorBlock(BlockSetType blockSetType, Properties properties) {
super(blockSetType, properties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.mojang.serialization.MapCodec;
import com.starfish_studios.seasons_greetings.registry.*;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.cauldron.CauldronInteraction;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.RandomSource;
Expand Down Expand Up @@ -39,6 +41,7 @@ public HotCocoaCauldronBlock(Properties properties, CauldronInteraction.Interact
return InteractionResult.PASS;
}


@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateDefinition) {
stateDefinition.add(LayeredCauldronBlock.LEVEL);
Expand Down Expand Up @@ -83,7 +86,14 @@ public void animateTick(BlockState blockState, Level level, BlockPos blockPos, R
}

protected @NotNull ItemInteractionResult useItemOn(ItemStack itemStack, BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult) {
if (itemStack.is(Items.GLASS_BOTTLE)) {
if (itemStack.is(Items.BUCKET)) {
player.playSound(SoundEvents.ARROW_HIT_PLAYER, 0.5F, level.random.nextFloat() * 0.1F + 0.9F);
player.displayClientMessage(Component.translatable("block.seasons_greetings.hot_cocoa_cauldron.bucket")
.withStyle(ChatFormatting.RED).withStyle(ChatFormatting.ITALIC), true);
return ItemInteractionResult.SUCCESS;
}

else if (itemStack.is(Items.GLASS_BOTTLE)) {
if (blockState.getValue(LayeredCauldronBlock.LEVEL) == 1) {
level.setBlockAndUpdate(blockPos, Blocks.CAULDRON.defaultBlockState());
if (!player.getInventory().add(new ItemStack(SGItems.HOT_COCOA_BOTTLE))) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package com.starfish_studios.seasons_greetings.block;

import com.mojang.serialization.MapCodec;
import com.starfish_studios.seasons_greetings.registry.*;
import net.minecraft.core.BlockPos;
import net.minecraft.core.cauldron.CauldronInteraction;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.AbstractCauldronBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LayeredCauldronBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.NotNull;

public class MilkCauldronBlock extends AbstractCauldronBlock {

@Override
protected MapCodec<? extends AbstractCauldronBlock> codec() {
return null;
}

public MilkCauldronBlock(Properties properties, CauldronInteraction.InteractionMap interactionMap) {
super(properties, interactionMap);
this.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3);
}

protected @NotNull InteractionResult useWithoutItem(BlockState blockState, Level level, BlockPos blockPos, Player player, BlockHitResult blockHitResult) {
return InteractionResult.PASS;
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateDefinition) {
stateDefinition.add(LayeredCauldronBlock.LEVEL);
}

public void animateTick(BlockState blockState, Level level, BlockPos blockPos, RandomSource randomSource) {
if (blockState.is(SGBlocks.MILK_CAULDRON) && level.getBlockState(blockPos.below()).is(SGTags.SGBlockTags.HEAT_SOURCES)) {
if (blockState.getValue(LayeredCauldronBlock.LEVEL) == 3) {
for (int i = 0; i < 2; ++i) {
double x = (double) blockPos.getX() + 0.3 + ((level.random.nextDouble() * 0.8D) - 0.2D);
double y = (double) blockPos.getY() + 1 + (level.random.nextDouble() * 0.2D - 0.1D);
double z = (double) blockPos.getZ() + 0.3 + ((level.random.nextDouble() * 0.8D) - 0.2D);

level.addParticle(SGParticles.MILK_BUBBLE, x, y, z, 0.0D, 0.0D, 0.0D);
}
} else if (blockState.getValue(LayeredCauldronBlock.LEVEL) == 2) {
for (int i = 0; i < 2; ++i) {
double x = (double) blockPos.getX() + 0.3 + ((level.random.nextDouble() * 0.8D) - 0.2D);
double y = (double) blockPos.getY() + 0.8 + (level.random.nextDouble() * 0.2D - 0.1D);
double z = (double) blockPos.getZ() + 0.3 + ((level.random.nextDouble() * 0.8D) - 0.2D);

level.addParticle(SGParticles.MILK_BUBBLE, x, y, z, 0.0D, 0.0D, 0.0D);
}
} else if (blockState.getValue(LayeredCauldronBlock.LEVEL) == 1) {
for (int i = 0; i < 2; ++i) {
double x = (double) blockPos.getX() + 0.3 + ((level.random.nextDouble() * 0.8D) - 0.2D);
double y = (double) blockPos.getY() + 0.6 + (level.random.nextDouble() * 0.2D - 0.1D);
double z = (double) blockPos.getZ() + 0.3 + ((level.random.nextDouble() * 0.8D) - 0.2D);

level.addParticle(SGParticles.MILK_BUBBLE, x, y, z, 0.0D, 0.0D, 0.0D);
}
}


if (randomSource.nextInt(10) == 0) {
level.playLocalSound((double) blockPos.getX() + 0.5, (double) blockPos.getY() + 0.5, (double) blockPos.getZ() + 0.5,
SGSoundEvents.MILK_BUBBLE, SoundSource.BLOCKS,
0.3F, 1.0F + level.random.nextFloat() * 0.2F, false);
}
}

}

protected @NotNull ItemInteractionResult useItemOn(ItemStack itemStack, BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult) {
if (itemStack.is(Items.BUCKET)) {
level.setBlockAndUpdate(blockPos, Blocks.CAULDRON.defaultBlockState());
if (!player.isCreative()) {
itemStack.shrink(1);
if (!player.getInventory().add(new ItemStack(Items.MILK_BUCKET))) {
player.drop(new ItemStack(Items.MILK_BUCKET), false);
}
}
player.playSound(SoundEvents.BUCKET_FILL, 1.0F, 1.0F);
return ItemInteractionResult.SUCCESS;
}

else if (itemStack.is(Items.GLASS_BOTTLE)) {
if (blockState.getValue(LayeredCauldronBlock.LEVEL) == 1) {
level.setBlockAndUpdate(blockPos, Blocks.CAULDRON.defaultBlockState());
if (!player.getInventory().add(new ItemStack(SGItems.WARM_MILK_BOTTLE))) {
player.drop(new ItemStack(SGItems.WARM_MILK_BOTTLE), false);
}
player.playSound(SoundEvents.BOTTLE_FILL, 1.0F, 1.0F);
return ItemInteractionResult.SUCCESS;
} else if (blockState.getValue(LayeredCauldronBlock.LEVEL) > 1) {
level.setBlockAndUpdate(blockPos, blockState.setValue(LayeredCauldronBlock.LEVEL, blockState.getValue(LayeredCauldronBlock.LEVEL) - 1));
if (!player.getInventory().add(new ItemStack(SGItems.WARM_MILK_BOTTLE))) {
player.drop(new ItemStack(SGItems.WARM_MILK_BOTTLE), false);
}
player.playSound(SoundEvents.BOTTLE_FILL, 1.0F, 1.0F);
return ItemInteractionResult.SUCCESS;
}
}

return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}

@Override
public boolean isFull(BlockState blockState) {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,30 @@

import com.starfish_studios.seasons_greetings.SeasonsGreetings;
import com.starfish_studios.seasons_greetings.client.gui.screens.GiftBoxScreen;
import com.starfish_studios.seasons_greetings.client.particles.CocoaBubbleParticle;
import com.starfish_studios.seasons_greetings.item.GiftBoxItem;
import com.starfish_studios.seasons_greetings.registry.SGBlocks;
import com.starfish_studios.seasons_greetings.registry.SGItems;
import com.starfish_studios.seasons_greetings.registry.SGMenus;
import com.starfish_studios.seasons_greetings.registry.SGParticles;
import com.starfish_studios.seasons_greetings.client.particles.PoppingBubbleParticle;
import com.starfish_studios.seasons_greetings.client.renderer.GingerbreadManRenderer;
import com.starfish_studios.seasons_greetings.registry.*;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.core.component.DataComponents;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.CustomData;

import java.awt.*;
import java.util.Objects;

@Environment(EnvType.CLIENT)
public class SeasonsGreetingsClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
registerRenderers();
registerScreens();
registerParticles();
registerEntityModelLayers();

ItemProperties.register(SGItems.RED_GIFT_BOX, SeasonsGreetings.id("bow_color"), (stack, world, entity, num) -> {
CustomData customData = stack.get(DataComponents.BLOCK_ENTITY_DATA);
Expand Down Expand Up @@ -66,18 +57,24 @@ public void onInitializeClient() {
});
}

private static void registerEntityModelLayers() {
EntityRendererRegistry.register(SGEntityType.GINGERBREAD_MAN, GingerbreadManRenderer::new);
}

public static void registerScreens() {
MenuScreens.register(SGMenus.GIFT_BOX, GiftBoxScreen::new);
}

private static void registerParticles() {
ParticleFactoryRegistry.getInstance().register(SGParticles.COCOA_BUBBLE, CocoaBubbleParticle.Provider::new);
ParticleFactoryRegistry.getInstance().register(SGParticles.COCOA_BUBBLE, PoppingBubbleParticle.Provider::new);
ParticleFactoryRegistry.getInstance().register(SGParticles.MILK_BUBBLE, PoppingBubbleParticle.Provider::new);
}

@SuppressWarnings("all")
public static void registerRenderers() {
BlockRenderLayerMap.INSTANCE.putBlocks(RenderType.cutout(),
SGBlocks.STRING_LIGHTS,
SGBlocks.WREATH,

SGBlocks.WHITE_GIFT_BOX,
SGBlocks.LIGHT_GRAY_GIFT_BOX,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.starfish_studios.seasons_greetings.client.model;

import com.starfish_studios.seasons_greetings.SeasonsGreetings;
import com.starfish_studios.seasons_greetings.entity.GingerbreadMan;
import com.starfish_studios.seasons_greetings.registry.SGBlocks;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.resources.ResourceLocation;
import software.bernie.geckolib.animation.AnimationState;
import software.bernie.geckolib.cache.object.GeoBone;
import software.bernie.geckolib.model.DefaultedEntityGeoModel;

@Environment(EnvType.CLIENT)
public class GingerbreadManModel extends DefaultedEntityGeoModel<GingerbreadMan> {

public GingerbreadManModel() {
super(SeasonsGreetings.id("gingerbread_man"), true);
}

@Override
public ResourceLocation getModelResource(GingerbreadMan gingerbreadMan) {
return SeasonsGreetings.id("geo/entity/gingerbread_man.geo.json");
}

@Override
public ResourceLocation getTextureResource(GingerbreadMan gingerbreadMan) {
return SeasonsGreetings.id("textures/entity/gingerbread_man.png");
}

@Override
public ResourceLocation getAnimationResource(GingerbreadMan gingerbreadMan) {
return SeasonsGreetings.id("animations/gingerbread_man.animation.json");
}

@Override
public void setCustomAnimations(GingerbreadMan gingerbreadMan, long instanceId, AnimationState<GingerbreadMan> animationState) {

super.setCustomAnimations(gingerbreadMan, instanceId, animationState);
if (animationState == null) return;

GeoBone root = this.getAnimationProcessor().getBone("rootRot");

if (gingerbreadMan.getInBlockState().is(SGBlocks.MILK_CAULDRON)) {
root.setRotZ((float) Math.sin(System.currentTimeMillis() * 0.05D) * 0.1F);
}

}
}
Loading

0 comments on commit e204d80

Please sign in to comment.