Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement remaining cauldron behaviors
Potion cauldrons: will apply potion to submerged entities and will drop potion when broken Water, milk, and soup cauldrons now support boiling, will damage submerged entities and display cool particles
- Loading branch information
1 parent
0b55c9e
commit 5e659fe
Showing
10 changed files
with
221 additions
and
18 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
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
50 changes: 50 additions & 0 deletions
50
src/main/java/knightminer/inspirations/recipes/block/BoilingFourLayerCauldronBlock.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,50 @@ | ||
package knightminer.inspirations.recipes.block; | ||
|
||
import knightminer.inspirations.Inspirations; | ||
import knightminer.inspirations.library.InspirationsTags; | ||
import knightminer.inspirations.library.MiscUtil; | ||
import knightminer.inspirations.recipes.InspirationsRecipes; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.cauldron.CauldronInteraction; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.properties.BlockStateProperties; | ||
|
||
import java.util.Map; | ||
import java.util.Random; | ||
|
||
/** Cauldron block that has four layers and emits boiling particles when over fire */ | ||
public class BoilingFourLayerCauldronBlock extends FourLayerCauldronBlock { | ||
public static final DamageSource DAMAGE_BOIL = new DamageSource(Inspirations.prefix("boiling")).bypassArmor(); | ||
|
||
public BoilingFourLayerCauldronBlock(Properties props, Map<Item,CauldronInteraction> interactions) { | ||
super(props, interactions); | ||
} | ||
|
||
@Override | ||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { | ||
if (!world.isClientSide && isEntityInsideContent(state, pos, entity) && isBoiling(world, pos)) { | ||
entity.hurt(DAMAGE_BOIL, 2.0F); | ||
} | ||
} | ||
|
||
@Override | ||
public void animateTick(BlockState state, Level level, BlockPos pos, Random rand) { | ||
if (isBoiling(level, pos)) { | ||
MiscUtil.addParticles(InspirationsRecipes.boilingParticle, level, pos, 2, getContentHeight(state), rand); | ||
} | ||
} | ||
|
||
/** Checks if this cauldron is boiling */ | ||
public static boolean isBoiling(Level level, BlockPos pos) { | ||
BlockState state = level.getBlockState(pos.below()); | ||
if (state.is(InspirationsTags.Blocks.CAULDRON_FIRE)) { | ||
// if it has a lit property, use that (campfires, furnaces). Otherwise just needs to be in the tag | ||
return !state.hasProperty(BlockStateProperties.LIT) || state.getValue(BlockStateProperties.LIT); | ||
} | ||
return false; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/knightminer/inspirations/recipes/block/BoilingThreeLayerCauldronBlock.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 knightminer.inspirations.recipes.block; | ||
|
||
import knightminer.inspirations.library.MiscUtil; | ||
import knightminer.inspirations.recipes.InspirationsRecipes; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.cauldron.CauldronInteraction; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.biome.Biome.Precipitation; | ||
import net.minecraft.world.level.block.LayeredCauldronBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
import java.util.Map; | ||
import java.util.Random; | ||
import java.util.function.Predicate; | ||
|
||
import static knightminer.inspirations.recipes.block.BoilingFourLayerCauldronBlock.DAMAGE_BOIL; | ||
import static knightminer.inspirations.recipes.block.BoilingFourLayerCauldronBlock.isBoiling; | ||
|
||
/** Cauldron block that has four layers and emits boiling particles when over fire */ | ||
public class BoilingThreeLayerCauldronBlock extends LayeredCauldronBlock { | ||
public BoilingThreeLayerCauldronBlock(Properties props, Predicate<Precipitation> fillPredicate, Map<Item,CauldronInteraction> interactions) { | ||
super(props, fillPredicate, interactions); | ||
} | ||
|
||
@Override | ||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { | ||
if (!world.isClientSide && isEntityInsideContent(state, pos, entity)) { | ||
if (isBoiling(world, pos)) { | ||
entity.hurt(DAMAGE_BOIL, 2.0F); | ||
} | ||
if (entity.isOnFire()) { | ||
entity.clearFire(); | ||
if (entity.mayInteract(world, pos)) { | ||
this.handleEntityOnFireInside(state, world, pos); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void animateTick(BlockState state, Level level, BlockPos pos, Random rand) { | ||
if (isBoiling(level, pos)) { | ||
MiscUtil.addParticles(InspirationsRecipes.boilingParticle, level, pos, 2, getContentHeight(state), rand); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.