-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hot Cocoa, Warm Milk, Gingerbread house material bases, some fixes
- Loading branch information
1 parent
84a6590
commit e204d80
Showing
171 changed files
with
4,020 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/starfish_studios/seasons_greetings/block/BouncyBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/starfish_studios/seasons_greetings/block/GingerbreadDoorBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
src/main/java/com/starfish_studios/seasons_greetings/block/MilkCauldronBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/com/starfish_studios/seasons_greetings/client/model/GingerbreadManModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.