diff --git a/src/main/generated/.cache/c189bb4c92920ea572e0709157481155fe15e5dc b/src/main/generated/.cache/c189bb4c92920ea572e0709157481155fe15e5dc index 356db04..dd15375 100644 --- a/src/main/generated/.cache/c189bb4c92920ea572e0709157481155fe15e5dc +++ b/src/main/generated/.cache/c189bb4c92920ea572e0709157481155fe15e5dc @@ -1,4 +1,4 @@ -// 1.20.1 2023-12-25T12:17:16.6255073 Caffeinated/Recipes +// 1.20.1 2023-12-29T00:56:21.6334434 Caffeinated/Recipes 8673497eb207defcf0d042ff52b307325dcef6ee data\caffeinated\advancements\recipes\misc\coffee_beans_from_campfire_cooking.json 2b1061f72b3e9a1295c9aa4334d37c9dcb3dfc53 data\caffeinated\advancements\recipes\misc\java_banner_pattern.json a01565ba0bf9276c839227dfab5f9fa1083cb376 data\caffeinated\recipes\ground_coffee_block.json @@ -6,16 +6,16 @@ bb529f25b75b190a9da8518d7a0931d22cbaf194 data\caffeinated\advancements\recipes\d 06c7edbdec5cf1deb92d8e421279587f14aaab54 data\caffeinated\advancements\recipes\food\tiramisu.json 5dfbeda6e15d9e292a25fc4e3f33d71b2ab777cb data\caffeinated\recipes\coffee_beans_from_smoking.json f8bbfcc2f655643293992d2bc113858fedbcc78f data\caffeinated\recipes\tiramisu.json -0c5f3057fe5d2ccf6a5bd511a99c41f7c9270949 data\caffeinated\advancements\recipes\misc\coffee_beans_from_smoking.json cd15441554dc9c3417486d7787d4609ccb9888b8 data\caffeinated\recipes\ground_coffee.json +0c5f3057fe5d2ccf6a5bd511a99c41f7c9270949 data\caffeinated\advancements\recipes\misc\coffee_beans_from_smoking.json ca718ec02747f39187e77abb367019198eac644e data\caffeinated\recipes\brown_dye_from_ground_coffee.json d34b1b5cba65cbe93df946e3a6badee9edc69dc0 data\caffeinated\recipes\coffee_berries.json 7d3019bc5b37ce3328bf16cc9b8edb2eb0839802 data\caffeinated\advancements\recipes\food\tiramisu_from_slices.json ebc2f568cdba0689d1071919c8b4a6bd23cc8df4 data\caffeinated\recipes\coffee_bean_block.json 3f815caa0d14d9f4dd898dfd686a518ba07b5408 data\caffeinated\advancements\recipes\misc\brown_dye_from_ground_coffee.json f86c55d2f85321c89c00baa260f1964d8b81bdcf data\caffeinated\recipes\tiramisu_from_slices.json -9dd043aa58724c5f9d877d84071191951a251c2b data\caffeinated\recipes\coffee_beans_from_campfire_cooking.json 5721d4f7e3a65f7b6f387ec00ee996f73a2f51ee data\caffeinated\advancements\recipes\misc\coffee_beans.json +9dd043aa58724c5f9d877d84071191951a251c2b data\caffeinated\recipes\coffee_beans_from_campfire_cooking.json d466ced2e8e679a807bdbcee307e0eb5e6547942 data\caffeinated\recipes\java_banner_pattern.json 55a0f263de5782dd9ec9aecd1d1ae815e3760bdb data\caffeinated\advancements\recipes\decorations\ground_coffee_block.json b78f30260a00fcc80fd6b65b41be9adce06286c9 data\caffeinated\recipes\coffee_beans.json diff --git a/src/main/generated/.cache/f97ece2f3a543d4dbc8c984a7bcdf2d64b8f7bed b/src/main/generated/.cache/f97ece2f3a543d4dbc8c984a7bcdf2d64b8f7bed index b38dbcf..17645d2 100644 --- a/src/main/generated/.cache/f97ece2f3a543d4dbc8c984a7bcdf2d64b8f7bed +++ b/src/main/generated/.cache/f97ece2f3a543d4dbc8c984a7bcdf2d64b8f7bed @@ -1,18 +1,19 @@ -// 1.20.1 2023-12-25T12:17:16.62302 Caffeinated/Model Definitions +// 1.20.1 2023-12-29T00:56:21.6297394 Caffeinated/Model Definitions da4528a3cfafc1ab21e5814b64029c10ec357178 assets\caffeinated\blockstates\ground_coffee_block.json 26f35f3a03b0d53578efd2c555721b08353d75f0 assets\caffeinated\blockstates\coffee_cauldron.json b1a481861132973fe035c9b9ce7613e15938034c assets\caffeinated\models\block\coffee_berry_crate.json e8f1792493d7219e1da4ac39e45bf903a349e3f5 assets\caffeinated\models\block\ground_coffee_cauldron_full.json cd360bb185f465f81672c32ac31312f77270e5f4 assets\caffeinated\models\block\coffee_cauldron_level2.json 57311e73aae426dff5d3b58c69ec071360f952d3 assets\caffeinated\models\block\ground_coffee_cauldron_level1.json -d233510c7f2129139eb5ce115540e88a680557d7 assets\caffeinated\blockstates\soul_cauldron_campfire.json +13297d4a51cb3b1369630338ba5f7b439b4af3fc assets\caffeinated\models\block\cauldron_campfire_filled.json cd254ba40cfd07d6c01d66a963e5ec83ed478aef assets\caffeinated\blockstates\coffee_berry_crate.json +ace2f8060adedf59471fa9728ad427b7c2abb51e assets\caffeinated\blockstates\soul_cauldron_campfire.json cdbc1b9ed3c8b04b24b80402af15eb777423817d assets\caffeinated\models\block\ground_coffee_cauldron_level2.json 1297909cbb77803c3f1a796d29fa088c9aeae546 assets\caffeinated\blockstates\coffee_shrub.json 34202786f9a57de99cd6cc7be5013c91a1b9690a assets\caffeinated\models\item\tiramisu_slice.json 86a7f801b70c8f877d0e3d52a8bce349a9232c4f assets\caffeinated\models\block\ground_coffee_block.json -2e82d1add55c94e56c5b85172449dc9ff539882d assets\caffeinated\models\block\coffee_cauldron_full.json 37d547b30cad973f0223896df68f15c5eea49d4b assets\caffeinated\models\item\ground_coffee_block.json +2e82d1add55c94e56c5b85172449dc9ff539882d assets\caffeinated\models\block\coffee_cauldron_full.json fe9155058173a06c1325878e72a8f42b0acfb9d7 assets\caffeinated\models\block\coffee_shrub_stage1.json 2078aae9dd460adbf0bf14e46615e32012f351e8 assets\caffeinated\blockstates\ground_coffee_cauldron.json 865a21f6601205d70079dbcc9d2bc9d375fbbc73 assets\caffeinated\models\block\coffee_bean_block.json @@ -23,13 +24,14 @@ fe9155058173a06c1325878e72a8f42b0acfb9d7 assets\caffeinated\models\block\coffee_ 2ee0688f44b78a48941720e3223b7bf3a9133161 assets\caffeinated\blockstates\potted_coffee_shrub.json 358965a77d8a9ace29f9981a460163089349eda2 assets\caffeinated\models\item\coffee_berry_crate.json 196754b26a9f9cac1bf6b81563cef5344f998868 assets\caffeinated\blockstates\tiramisu.json -50804beb94c1a58c883df514333ff7d2c2807a42 assets\caffeinated\models\item\coffee_bean_block.json ee814f36f99a123b06cf2e7bcb08415b97595925 assets\caffeinated\models\block\potted_coffee_shrub.json +50804beb94c1a58c883df514333ff7d2c2807a42 assets\caffeinated\models\item\coffee_bean_block.json 6bc7bd9e663e1a1e43a79ef46957b15c4682a3a6 assets\caffeinated\models\block\coffee_shrub_stage0.json 0dab1d0bc7608970cc968c8f8569497fae0b2295 assets\caffeinated\models\item\ground_coffee.json -8c0a558dd56b8bb92576690cceb337b2997cdf33 assets\caffeinated\blockstates\cauldron_campfire.json +ffcb5afccb3a6b30399f263654799949096594da assets\caffeinated\blockstates\cauldron_campfire.json 58f78eb6198fba07304fece9e3c7bb6247a13229 assets\caffeinated\models\item\coffee_bottle.json 6568f0e38ffcef7753bd7c0ae1bfdd66fafc6795 assets\caffeinated\models\block\cauldron_campfire.json e4c8f2b75d3ecafc48e0a48ec6940b6dac0eb258 assets\caffeinated\models\item\coffee_beans.json 66ab3c0788a1452c84c9c06f8ffe0bf7828a9620 assets\caffeinated\models\item\java_banner_pattern.json 1564a118add7b691cd3d6b1b6d06641507f0a7e2 assets\caffeinated\models\item\coffee_berries.json +f231ba05786d3928e6a0fce4139f5e1c5b106036 assets\caffeinated\models\block\soul_cauldron_campfire_filled.json diff --git a/src/main/generated/assets/caffeinated/blockstates/cauldron_campfire.json b/src/main/generated/assets/caffeinated/blockstates/cauldron_campfire.json index 37bd391..e448057 100644 --- a/src/main/generated/assets/caffeinated/blockstates/cauldron_campfire.json +++ b/src/main/generated/assets/caffeinated/blockstates/cauldron_campfire.json @@ -1,34 +1,64 @@ { "variants": { - "facing=east,lit=false": { + "facing=east,filled=false,lit=false": { "model": "caffeinated:block/cauldron_campfire_off", "y": 270 }, - "facing=east,lit=true": { + "facing=east,filled=false,lit=true": { "model": "caffeinated:block/cauldron_campfire", "y": 270 }, - "facing=north,lit=false": { + "facing=east,filled=true,lit=false": { + "model": "caffeinated:block/cauldron_campfire_off_filled", + "y": 270 + }, + "facing=east,filled=true,lit=true": { + "model": "caffeinated:block/cauldron_campfire_filled", + "y": 270 + }, + "facing=north,filled=false,lit=false": { "model": "caffeinated:block/cauldron_campfire_off", "y": 180 }, - "facing=north,lit=true": { + "facing=north,filled=false,lit=true": { "model": "caffeinated:block/cauldron_campfire", "y": 180 }, - "facing=south,lit=false": { + "facing=north,filled=true,lit=false": { + "model": "caffeinated:block/cauldron_campfire_off_filled", + "y": 180 + }, + "facing=north,filled=true,lit=true": { + "model": "caffeinated:block/cauldron_campfire_filled", + "y": 180 + }, + "facing=south,filled=false,lit=false": { "model": "caffeinated:block/cauldron_campfire_off" }, - "facing=south,lit=true": { + "facing=south,filled=false,lit=true": { "model": "caffeinated:block/cauldron_campfire" }, - "facing=west,lit=false": { + "facing=south,filled=true,lit=false": { + "model": "caffeinated:block/cauldron_campfire_off_filled" + }, + "facing=south,filled=true,lit=true": { + "model": "caffeinated:block/cauldron_campfire_filled" + }, + "facing=west,filled=false,lit=false": { "model": "caffeinated:block/cauldron_campfire_off", "y": 90 }, - "facing=west,lit=true": { + "facing=west,filled=false,lit=true": { "model": "caffeinated:block/cauldron_campfire", "y": 90 + }, + "facing=west,filled=true,lit=false": { + "model": "caffeinated:block/cauldron_campfire_off_filled", + "y": 90 + }, + "facing=west,filled=true,lit=true": { + "model": "caffeinated:block/cauldron_campfire_filled", + "y": 90 } } } \ No newline at end of file diff --git a/src/main/generated/assets/caffeinated/blockstates/soul_cauldron_campfire.json b/src/main/generated/assets/caffeinated/blockstates/soul_cauldron_campfire.json index 82e4be8..44c6f47 100644 --- a/src/main/generated/assets/caffeinated/blockstates/soul_cauldron_campfire.json +++ b/src/main/generated/assets/caffeinated/blockstates/soul_cauldron_campfire.json @@ -1,34 +1,64 @@ { "variants": { - "facing=east,lit=false": { + "facing=east,filled=false,lit=false": { "model": "caffeinated:block/cauldron_campfire_off", "y": 270 }, - "facing=east,lit=true": { + "facing=east,filled=false,lit=true": { "model": "caffeinated:block/soul_cauldron_campfire", "y": 270 }, - "facing=north,lit=false": { + "facing=east,filled=true,lit=false": { + "model": "caffeinated:block/cauldron_campfire_off_filled", + "y": 270 + }, + "facing=east,filled=true,lit=true": { + "model": "caffeinated:block/soul_cauldron_campfire_filled", + "y": 270 + }, + "facing=north,filled=false,lit=false": { "model": "caffeinated:block/cauldron_campfire_off", "y": 180 }, - "facing=north,lit=true": { + "facing=north,filled=false,lit=true": { "model": "caffeinated:block/soul_cauldron_campfire", "y": 180 }, - "facing=south,lit=false": { + "facing=north,filled=true,lit=false": { + "model": "caffeinated:block/cauldron_campfire_off_filled", + "y": 180 + }, + "facing=north,filled=true,lit=true": { + "model": "caffeinated:block/soul_cauldron_campfire_filled", + "y": 180 + }, + "facing=south,filled=false,lit=false": { "model": "caffeinated:block/cauldron_campfire_off" }, - "facing=south,lit=true": { + "facing=south,filled=false,lit=true": { "model": "caffeinated:block/soul_cauldron_campfire" }, - "facing=west,lit=false": { + "facing=south,filled=true,lit=false": { + "model": "caffeinated:block/cauldron_campfire_off_filled" + }, + "facing=south,filled=true,lit=true": { + "model": "caffeinated:block/soul_cauldron_campfire_filled" + }, + "facing=west,filled=false,lit=false": { "model": "caffeinated:block/cauldron_campfire_off", "y": 90 }, - "facing=west,lit=true": { + "facing=west,filled=false,lit=true": { "model": "caffeinated:block/soul_cauldron_campfire", "y": 90 + }, + "facing=west,filled=true,lit=false": { + "model": "caffeinated:block/cauldron_campfire_off_filled", + "y": 90 + }, + "facing=west,filled=true,lit=true": { + "model": "caffeinated:block/soul_cauldron_campfire_filled", + "y": 90 } } } \ No newline at end of file diff --git a/src/main/generated/assets/caffeinated/models/block/cauldron_campfire_filled.json b/src/main/generated/assets/caffeinated/models/block/cauldron_campfire_filled.json new file mode 100644 index 0000000..aa1ef6e --- /dev/null +++ b/src/main/generated/assets/caffeinated/models/block/cauldron_campfire_filled.json @@ -0,0 +1,7 @@ +{ + "parent": "caffeinated:block/template_cauldron_campfire_filled", + "textures": { + "fire": "minecraft:block/campfire_fire", + "lit_log": "minecraft:block/campfire_log_lit" + } +} \ No newline at end of file diff --git a/src/main/generated/assets/caffeinated/models/block/soul_cauldron_campfire_filled.json b/src/main/generated/assets/caffeinated/models/block/soul_cauldron_campfire_filled.json new file mode 100644 index 0000000..801ca78 --- /dev/null +++ b/src/main/generated/assets/caffeinated/models/block/soul_cauldron_campfire_filled.json @@ -0,0 +1,7 @@ +{ + "parent": "caffeinated:block/template_cauldron_campfire_filled", + "textures": { + "fire": "minecraft:block/soul_campfire_fire", + "lit_log": "minecraft:block/soul_campfire_log_lit" + } +} \ No newline at end of file diff --git a/src/main/java/com/chikoritalover/caffeinated/Caffeinated.java b/src/main/java/com/chikoritalover/caffeinated/Caffeinated.java index fcf55c5..2f73ddf 100644 --- a/src/main/java/com/chikoritalover/caffeinated/Caffeinated.java +++ b/src/main/java/com/chikoritalover/caffeinated/Caffeinated.java @@ -1,11 +1,13 @@ package com.chikoritalover.caffeinated; +import com.chikoritalover.caffeinated.advancement.BrewCoffeeCriterion; import com.chikoritalover.caffeinated.block.entity.CauldronCampfireBlockEntity; import com.chikoritalover.caffeinated.registry.*; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.loot.v2.FabricLootPoolBuilder; import net.fabricmc.fabric.api.loot.v2.LootTableEvents; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; +import net.minecraft.advancement.criterion.Criteria; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.loot.LootPool; import net.minecraft.loot.LootTable; @@ -27,6 +29,7 @@ public class Caffeinated implements ModInitializer { // That way, it's clear which mod wrote info, warnings, and errors. public static final String MODID = "caffeinated"; public static final Logger LOGGER = LoggerFactory.getLogger("modid"); + public static final BrewCoffeeCriterion BREW_COFFEE_CRITERION = Criteria.register(new BrewCoffeeCriterion()); public static final BlockEntityType CAULDRON_CAMPFIRE = Registry.register( Registries.BLOCK_ENTITY_TYPE, new Identifier(MODID, "cauldron_campfire"), diff --git a/src/main/java/com/chikoritalover/caffeinated/CaffeinatedClient.java b/src/main/java/com/chikoritalover/caffeinated/CaffeinatedClient.java index 5288b20..4fbc473 100644 --- a/src/main/java/com/chikoritalover/caffeinated/CaffeinatedClient.java +++ b/src/main/java/com/chikoritalover/caffeinated/CaffeinatedClient.java @@ -1,5 +1,7 @@ package com.chikoritalover.caffeinated; +import com.chikoritalover.caffeinated.block.CauldronCampfireBlock; +import com.chikoritalover.caffeinated.block.entity.CauldronCampfireBlockEntity; import com.chikoritalover.caffeinated.registry.CaffeinatedBlocks; import com.chikoritalover.caffeinated.registry.CaffeinatedParticleTypes; import com.mojang.datafixers.util.Pair; @@ -7,6 +9,9 @@ import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; +import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; +import net.minecraft.block.Block; +import net.minecraft.client.color.world.BiomeColors; import net.minecraft.client.particle.BubblePopParticle; import net.minecraft.client.render.RenderLayer; import net.minecraft.entity.effect.StatusEffectInstance; @@ -27,6 +32,13 @@ public void onInitializeClient() { BlockRenderLayerMap.INSTANCE.putBlock(CaffeinatedBlocks.CAULDRON_CAMPFIRE, RenderLayer.getCutout()); BlockRenderLayerMap.INSTANCE.putBlock(CaffeinatedBlocks.SOUL_CAULDRON_CAMPFIRE, RenderLayer.getCutout()); + ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> { + if (world == null || pos == null || world.getBlockEntity(pos) == null) { + return BiomeColors.getWaterColor(world, pos); + } + return ((CauldronCampfireBlockEntity) world.getBlockEntity(pos)).getColor(); + }, CauldronCampfireBlock.CAMPFIRE_TO_CAULDRON_CAMPFIRE.values().toArray(new Block[0])); + ParticleFactoryRegistry.getInstance().register(CaffeinatedParticleTypes.COFFEE_POP, BubblePopParticle.Factory::new); ItemTooltipCallback.EVENT.register((stack, context, lines) -> { diff --git a/src/main/java/com/chikoritalover/caffeinated/CaffeinatedDataGenerator.java b/src/main/java/com/chikoritalover/caffeinated/CaffeinatedDataGenerator.java index a314a44..f4856d4 100644 --- a/src/main/java/com/chikoritalover/caffeinated/CaffeinatedDataGenerator.java +++ b/src/main/java/com/chikoritalover/caffeinated/CaffeinatedDataGenerator.java @@ -44,7 +44,9 @@ private CaffeinatedModelGenerator(FabricDataOutput output) { public final void registerCauldronCampfire(BlockStateModelGenerator blockStateModelGenerator, Block cauldronCampfire, Block campfire) { Identifier identifier = new Identifier(Caffeinated.MODID, "block/cauldron_campfire_off"); Identifier identifier2 = new Model(Optional.of(new Identifier(Caffeinated.MODID, "block/template_cauldron_campfire")), Optional.empty(), TextureKey.FIRE, TextureKey.LIT_LOG).upload(cauldronCampfire, TextureMap.campfire(campfire), blockStateModelGenerator.modelCollector); - blockStateModelGenerator.blockStateCollector.accept(VariantsBlockStateSupplier.create(cauldronCampfire).coordinate(BlockStateModelGenerator.createBooleanModelMap(Properties.LIT, identifier2, identifier)).coordinate(BlockStateModelGenerator.createSouthDefaultHorizontalRotationStates())); + Identifier identifier3 = new Identifier(Caffeinated.MODID, "block/cauldron_campfire_off_filled"); + Identifier identifier4 = new Model(Optional.of(new Identifier(Caffeinated.MODID, "block/template_cauldron_campfire_filled")), Optional.empty(), TextureKey.FIRE, TextureKey.LIT_LOG).upload(ModelIds.getBlockSubModelId(cauldronCampfire, "_filled"), TextureMap.campfire(campfire), blockStateModelGenerator.modelCollector); + blockStateModelGenerator.blockStateCollector.accept(VariantsBlockStateSupplier.create(cauldronCampfire).coordinate(BlockStateModelGenerator.createSouthDefaultHorizontalRotationStates()).coordinate(BlockStateVariantMap.create(Properties.LIT, CauldronCampfireBlock.FILLED).register(false, false, BlockStateVariant.create().put(VariantSettings.MODEL, identifier)).register(true, false, BlockStateVariant.create().put(VariantSettings.MODEL, identifier2)).register(false, true, BlockStateVariant.create().put(VariantSettings.MODEL, identifier3)).register(true, true, BlockStateVariant.create().put(VariantSettings.MODEL, identifier4)))); } public final void registerCoffeeShrub(BlockStateModelGenerator blockStateModelGenerator, Block crop, Block pottedCrop, Property ageProperty, int... ageTextureIndices) { diff --git a/src/main/java/com/chikoritalover/caffeinated/advancement/BrewCoffeeCriterion.java b/src/main/java/com/chikoritalover/caffeinated/advancement/BrewCoffeeCriterion.java new file mode 100644 index 0000000..dcb7b5f --- /dev/null +++ b/src/main/java/com/chikoritalover/caffeinated/advancement/BrewCoffeeCriterion.java @@ -0,0 +1,52 @@ +package com.chikoritalover.caffeinated.advancement; + +import com.chikoritalover.caffeinated.Caffeinated; +import com.google.gson.JsonObject; +import net.minecraft.advancement.criterion.AbstractCriterion; +import net.minecraft.advancement.criterion.AbstractCriterionConditions; +import net.minecraft.item.ItemStack; +import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer; +import net.minecraft.predicate.entity.AdvancementEntityPredicateSerializer; +import net.minecraft.predicate.entity.LootContextPredicate; +import net.minecraft.predicate.item.ItemPredicate; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; + +public class BrewCoffeeCriterion extends AbstractCriterion { + static final Identifier ID = new Identifier(Caffeinated.MODID, "brew_coffee"); + + @Override + protected Conditions conditionsFromJson(JsonObject obj, LootContextPredicate playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) { + ItemPredicate itemPredicate = ItemPredicate.fromJson(obj.get("item")); + return new Conditions(playerPredicate, itemPredicate); + } + + @Override + public Identifier getId() { + return ID; + } + + public void trigger(ServerPlayerEntity player, ItemStack stack) { + this.trigger(player, conditions -> conditions.matches(stack)); + } + + public static class Conditions extends AbstractCriterionConditions { + private final ItemPredicate itemPredicate; + + public Conditions(LootContextPredicate player, ItemPredicate item) { + super(ID, player); + this.itemPredicate = item; + } + + public boolean matches(ItemStack stack) { + return this.itemPredicate.test(stack); + } + + @Override + public JsonObject toJson(AdvancementEntityPredicateSerializer predicateSerializer) { + JsonObject jsonObject = super.toJson(predicateSerializer); + jsonObject.add("item", this.itemPredicate.toJson()); + return jsonObject; + } + } +} diff --git a/src/main/java/com/chikoritalover/caffeinated/block/CauldronCampfireBlock.java b/src/main/java/com/chikoritalover/caffeinated/block/CauldronCampfireBlock.java index adf4ea4..40f2467 100644 --- a/src/main/java/com/chikoritalover/caffeinated/block/CauldronCampfireBlock.java +++ b/src/main/java/com/chikoritalover/caffeinated/block/CauldronCampfireBlock.java @@ -3,6 +3,8 @@ import com.chikoritalover.caffeinated.Caffeinated; import com.chikoritalover.caffeinated.block.entity.CauldronCampfireBlockEntity; import com.chikoritalover.caffeinated.registry.CaffeinatedBlockTags; +import com.chikoritalover.caffeinated.registry.CaffeinatedSoundEvents; +import com.chikoritalover.caffeinated.registry.CaffeinatedStats; import com.google.common.collect.Maps; import net.minecraft.block.*; import net.minecraft.block.entity.BlockEntity; @@ -10,22 +12,31 @@ import net.minecraft.block.entity.BlockEntityType; import net.minecraft.entity.Entity; import net.minecraft.entity.ai.pathing.NavigationType; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.fluid.FluidState; import net.minecraft.fluid.Fluids; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUsage; +import net.minecraft.item.Items; import net.minecraft.loot.context.LootContextParameterSet; import net.minecraft.particle.ParticleEffect; -import net.minecraft.particle.ParticleType; import net.minecraft.particle.ParticleTypes; +import net.minecraft.potion.PotionUtil; +import net.minecraft.potion.Potions; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; +import net.minecraft.stat.Stats; import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; +import net.minecraft.util.ActionResult; import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockRotation; +import net.minecraft.util.Hand; import net.minecraft.util.function.BooleanBiFunction; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; @@ -37,6 +48,7 @@ import net.minecraft.world.BlockView; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; +import net.minecraft.world.biome.Biome; import net.minecraft.world.event.GameEvent; import org.jetbrains.annotations.Nullable; @@ -44,12 +56,13 @@ import java.util.Map; public class CauldronCampfireBlock extends BlockWithEntity implements Waterloggable { - protected static final VoxelShape COLLISION_SHAPE = Block.createCuboidShape(0.5, 0.0, 0.5, 15.5, 16.0, 15.5); - protected static final VoxelShape OUTLINE_SHAPE = VoxelShapes.combineAndSimplify(Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 7.0, 16.0), Block.createCuboidShape(2.0, 5.0, 2.0, 14.0, 16.0, 14.0), BooleanBiFunction.OR); + public static final BooleanProperty FILLED = BooleanProperty.of("filled"); public static final BooleanProperty LIT = Properties.LIT; public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING; public static final Map CAMPFIRE_TO_CAULDRON_CAMPFIRE = Maps.newHashMap(); + protected static final VoxelShape COLLISION_SHAPE = Block.createCuboidShape(0.5, 0.0, 0.5, 15.5, 16.0, 15.5); + protected static final VoxelShape OUTLINE_SHAPE = VoxelShapes.combineAndSimplify(Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 7.0, 16.0), Block.createCuboidShape(2.0, 5.0, 2.0, 14.0, 16.0, 14.0), BooleanBiFunction.OR); private final Block baseBlock; private final ParticleEffect particleEffect; @@ -58,7 +71,77 @@ public CauldronCampfireBlock(Block baseBlock, ParticleEffect particleEffect, Set this.baseBlock = baseBlock; this.particleEffect = particleEffect; CAMPFIRE_TO_CAULDRON_CAMPFIRE.put(baseBlock, this); - this.setDefaultState(this.getStateManager().getDefaultState().with(LIT, true).with(WATERLOGGED, false).with(FACING, Direction.NORTH)); + this.setDefaultState(this.getStateManager().getDefaultState().with(FILLED, false).with(LIT, true).with(WATERLOGGED, false).with(FACING, Direction.NORTH)); + } + + public static void extinguish(@Nullable Entity entity, WorldAccess world, BlockPos pos, BlockState state) { + if (world.isClient()) { + for (int i = 0; i < 20; i++) { + CampfireBlock.spawnSmokeParticle((World) world, pos, false, true); + } + } + + world.emitGameEvent(entity, GameEvent.BLOCK_CHANGE, pos); + } + + public static void spawnSmokeParticle(World world, BlockPos pos, boolean lotsOfSmoke) { + Random random = world.getRandom(); + float f = random.nextFloat() * MathHelper.PI * 2.0F; + world.addImportantParticle(ParticleTypes.CAMPFIRE_COSY_SMOKE, true, pos.getX() + 0.5 + MathHelper.sin(f) * 0.5, pos.getY() + random.nextDouble() + random.nextDouble(), pos.getZ() + 0.5 + MathHelper.cos(f) * 0.5, 0.0, 0.07, 0.0); + if (lotsOfSmoke) { + world.addParticle(ParticleTypes.SMOKE, pos.getX() + 0.5 + random.nextDouble() / 4.0 * (random.nextBoolean() ? 1.0 : -1.0), pos.getY() + 0.4, pos.getZ() + 0.5 + random.nextDouble() / 4.0 * (random.nextBoolean() ? 1.0 : -1.0), 0.0, 0.005, 0.0); + } + } + + public static boolean canBeLit(BlockState state) { + return state.isIn(CaffeinatedBlockTags.CAULDRON_CAMPFIRES, statex -> statex.contains(WATERLOGGED) && statex.contains(LIT)) && !state.get(WATERLOGGED) && !state.get(LIT); + } + + @Override + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + BlockEntity blockEntity = world.getBlockEntity(pos); + if (blockEntity instanceof CauldronCampfireBlockEntity cauldronCampfire) { + ItemStack stack = player.getStackInHand(hand); + Item item = stack.getItem(); + Item item2 = cauldronCampfire.getStack(0).getItem(); + boolean bl = !state.get(FILLED) && CauldronCampfireBlockEntity.isBaseIngredient(stack); + boolean bl2 = !cauldronCampfire.hasReagent() && CauldronCampfireBlockEntity.canBrewTogether(cauldronCampfire.getStack(0), stack); + boolean bl3 = state.get(FILLED) && (!item2.hasRecipeRemainder() || stack.isOf(item2.getRecipeRemainder())); + if (!bl && !bl2 && !bl3) { + return ActionResult.PASS; + } + if (!world.isClient()) { + if (bl) { + cauldronCampfire.addBaseIngredient(player, stack); + player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, item.getRecipeRemainder(stack))); + world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.emitGameEvent(null, GameEvent.FLUID_PLACE, pos); + } else if (bl2) { + cauldronCampfire.addReagent(player, stack); + player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, item.getRecipeRemainder(stack))); + world.playSound(null, pos, CaffeinatedSoundEvents.ITEM_GROUND_COFFEE_SPLASH, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.emitGameEvent(null, GameEvent.BLOCK_CHANGE, pos); + } else { + ItemStack itemStack = item2.getDefaultStack(); + if (stack.isOf(item2.getRecipeRemainder())) { + player.setStackInHand(hand, ItemUsage.exchangeStack(stack, player, item2.getDefaultStack())); + } else { + player.giveItemStack(item2.getDefaultStack()); + } + cauldronCampfire.clear(); + world.playSound(null, pos, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.emitGameEvent(null, GameEvent.FLUID_PICKUP, pos); + if (player instanceof ServerPlayerEntity serverPlayer) { + Caffeinated.BREW_COFFEE_CRITERION.trigger(serverPlayer, itemStack); + } + } + player.incrementStat(Stats.USED.getOrCreateStat(item)); + player.incrementStat(CaffeinatedStats.INTERACT_WITH_CAULDRON_CAMPFIRE); + } + return ActionResult.success(world.isClient()); + } else { + return ActionResult.PASS; + } } @Override @@ -99,23 +182,14 @@ public BlockRenderType getRenderType(BlockState state) { @Override public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { - if (state.get(LIT)) { - if (random.nextInt(10) == 0) { - world.playSoundAtBlockCenter(pos, SoundEvents.BLOCK_CAMPFIRE_CRACKLE, SoundCategory.BLOCKS, 0.5F + random.nextFloat(), random.nextFloat() * 0.7F + 0.6F, false); - } - float f = random.nextFloat() * MathHelper.PI * 2.0F; - world.addParticle(this.particleEffect, pos.getX() + 0.5 + MathHelper.sin(f) * 0.45, pos.getY() + random.nextBetween(6, 8) / 16.0, pos.getZ() + 0.5 + MathHelper.cos(f) * 0.45, 0.0, 0.0, 0.0); + if (!state.get(LIT)) { + return; } - } - - public static void extinguish(@Nullable Entity entity, WorldAccess world, BlockPos pos, BlockState state) { - if (world.isClient()) { - for (int i = 0; i < 20; i++) { - CampfireBlock.spawnSmokeParticle((World) world, pos, false, true); - } + if (random.nextInt(10) == 0) { + world.playSoundAtBlockCenter(pos, SoundEvents.BLOCK_CAMPFIRE_CRACKLE, SoundCategory.BLOCKS, 0.5F + random.nextFloat(), random.nextFloat() * 0.7F + 0.6F, false); } - - world.emitGameEvent(entity, GameEvent.BLOCK_CHANGE, pos); + float f = random.nextFloat() * MathHelper.PI * 2.0F; + world.addParticle(this.particleEffect, pos.getX() + 0.5 + MathHelper.sin(f) * 0.45, pos.getY() + random.nextBetween(6, 8) / 16.0, pos.getZ() + 0.5 + MathHelper.cos(f) * 0.45, 0.0, 0.0, 0.0); } @Override @@ -134,6 +208,17 @@ public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState stat } } + @Override + public void precipitationTick(BlockState state, World world, BlockPos pos, Biome.Precipitation precipitation) { + if ((precipitation == Biome.Precipitation.RAIN || precipitation == Biome.Precipitation.SNOW) && world.getRandom().nextFloat() < 0.05F) { + BlockEntity blockEntity = world.getBlockEntity(pos); + if (blockEntity instanceof CauldronCampfireBlockEntity cauldronCampfire && !state.get(FILLED)) { + cauldronCampfire.addBaseIngredient(null, PotionUtil.setPotion(Items.POTION.getDefaultStack(), Potions.WATER)); + } + world.emitGameEvent(null, GameEvent.BLOCK_CHANGE, pos); + } + } + @Override public void onProjectileHit(World world, BlockState state, BlockHitResult hit, ProjectileEntity projectile) { BlockPos blockPos = hit.getBlockPos(); @@ -142,15 +227,6 @@ public void onProjectileHit(World world, BlockState state, BlockHitResult hit, P } } - public static void spawnSmokeParticle(World world, BlockPos pos, boolean lotsOfSmoke) { - Random random = world.getRandom(); - float f = random.nextFloat() * MathHelper.PI * 2.0F; - world.addImportantParticle(ParticleTypes.CAMPFIRE_COSY_SMOKE, true, pos.getX() + 0.5 + MathHelper.sin(f) * 0.5, pos.getY() + random.nextDouble() + random.nextDouble(), pos.getZ() + 0.5 + MathHelper.cos(f) * 0.5, 0.0, 0.07, 0.0); - if (lotsOfSmoke) { - world.addParticle(ParticleTypes.SMOKE, pos.getX() + 0.5 + random.nextDouble() / 4.0 * (random.nextBoolean() ? 1.0 : -1.0), pos.getY() + 0.4, pos.getZ() + 0.5 + random.nextDouble() / 4.0 * (random.nextBoolean() ? 1.0 : -1.0), 0.0, 0.005, 0.0); - } - } - @Override public FluidState getFluidState(BlockState state) { return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); @@ -168,7 +244,7 @@ public BlockState mirror(BlockState state, BlockMirror mirror) { @Override protected void appendProperties(StateManager.Builder builder) { - builder.add(LIT, WATERLOGGED, FACING); + builder.add(FILLED, LIT, WATERLOGGED, FACING); } @Nullable @@ -179,8 +255,8 @@ public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { @Nullable public BlockEntityTicker getTicker(World world, BlockState state, BlockEntityType type) { - if (world.isClient) { - return state.get(LIT) ? checkType(type, Caffeinated.CAULDRON_CAMPFIRE, CauldronCampfireBlockEntity::clientTick) : null; + if (state.get(LIT)) { + return checkType(type, Caffeinated.CAULDRON_CAMPFIRE, world.isClient() ? CauldronCampfireBlockEntity::clientTick : CauldronCampfireBlockEntity::litServerTick); } return null; } @@ -190,10 +266,6 @@ public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos po return false; } - public static boolean canBeLit(BlockState state) { - return state.isIn(CaffeinatedBlockTags.CAULDRON_CAMPFIRES, statex -> statex.contains(WATERLOGGED) && statex.contains(LIT)) && !state.get(WATERLOGGED) && !state.get(LIT); - } - private BlockState getBaseBlockState(BlockState state) { if (this.baseBlock instanceof CampfireBlock campfireBlock) { return campfireBlock.getDefaultState().with(FACING, state.get(FACING)).with(LIT, state.get(LIT)).with(WATERLOGGED, state.get(WATERLOGGED)); diff --git a/src/main/java/com/chikoritalover/caffeinated/block/CoffeeCauldronBlock.java b/src/main/java/com/chikoritalover/caffeinated/block/CoffeeCauldronBlock.java index f593976..02f2061 100644 --- a/src/main/java/com/chikoritalover/caffeinated/block/CoffeeCauldronBlock.java +++ b/src/main/java/com/chikoritalover/caffeinated/block/CoffeeCauldronBlock.java @@ -59,7 +59,7 @@ public void randomDisplayTick(BlockState state, World world, BlockPos pos, Rando double e = pos.getY() + 0.375 + level * 0.1875; double f = pos.getZ() + random.nextDouble() * 0.5 + 0.25; if (random.nextDouble() < 0.15) { - world.playSound(d, e, f, CaffeinatedSoundEvents.BLOCK_CAULDRON_BUBBLE, SoundCategory.BLOCKS, 0.2F, 2.5F - level * 0.5F, true); + world.playSound(d, e, f, CaffeinatedSoundEvents.BLOCK_CAULDRON_CAMPFIRE_BUBBLE, SoundCategory.BLOCKS, 0.2F, 2.5F - level * 0.5F, true); } world.addParticle(getPopParticleEffect(), d, e, f, 0.0, 0.0, 0.0); diff --git a/src/main/java/com/chikoritalover/caffeinated/block/GroundCoffeeCauldronBlock.java b/src/main/java/com/chikoritalover/caffeinated/block/GroundCoffeeCauldronBlock.java index e24c1b6..919b2cf 100644 --- a/src/main/java/com/chikoritalover/caffeinated/block/GroundCoffeeCauldronBlock.java +++ b/src/main/java/com/chikoritalover/caffeinated/block/GroundCoffeeCauldronBlock.java @@ -45,7 +45,7 @@ public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Ran world.setBlockState(pos, blockState); world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(blockState)); - world.playSound(null, pos, CaffeinatedSoundEvents.BLOCK_CAULDRON_BREW, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.playSound(null, pos, CaffeinatedSoundEvents.BLOCK_CAULDRON_CAMPFIRE_BREW, SoundCategory.BLOCKS, 1.0F, 1.0F); } } } diff --git a/src/main/java/com/chikoritalover/caffeinated/block/entity/CauldronCampfireBlockEntity.java b/src/main/java/com/chikoritalover/caffeinated/block/entity/CauldronCampfireBlockEntity.java index 1d345e8..37ec459 100644 --- a/src/main/java/com/chikoritalover/caffeinated/block/entity/CauldronCampfireBlockEntity.java +++ b/src/main/java/com/chikoritalover/caffeinated/block/entity/CauldronCampfireBlockEntity.java @@ -2,24 +2,170 @@ import com.chikoritalover.caffeinated.Caffeinated; import com.chikoritalover.caffeinated.block.CauldronCampfireBlock; +import com.chikoritalover.caffeinated.registry.CaffeinatedItems; +import com.chikoritalover.caffeinated.registry.CaffeinatedSoundEvents; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; +import net.minecraft.client.color.world.BiomeColors; +import net.minecraft.entity.Entity; +import net.minecraft.inventory.Inventories; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.potion.PotionUtil; +import net.minecraft.potion.Potions; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.sound.SoundCategory; +import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.random.Random; import net.minecraft.world.World; +import net.minecraft.world.event.GameEvent; +import org.jetbrains.annotations.Nullable; public class CauldronCampfireBlockEntity extends BlockEntity { + private DefaultedList inventory = DefaultedList.ofSize(2, ItemStack.EMPTY); + int brewingTime; + int brewingTimeTotal; + public CauldronCampfireBlockEntity(BlockPos pos, BlockState state) { super(Caffeinated.CAULDRON_CAMPFIRE, pos, state); + this.brewingTime = 0; + this.brewingTimeTotal = 600; + } + + public static void litServerTick(World world, BlockPos pos, BlockState state, CauldronCampfireBlockEntity cauldronCampfire) { + ItemStack stack = cauldronCampfire.getStack(0); + if (state.get(CauldronCampfireBlock.FILLED) && canBrewTogether(stack, cauldronCampfire.getStack(1))) { + cauldronCampfire.brewingTime++; + if (cauldronCampfire.brewingTime >= cauldronCampfire.brewingTimeTotal) { + cauldronCampfire.clear(); + cauldronCampfire.setStack(0, CaffeinatedItems.COFFEE_BOTTLE.getDefaultStack()); + world.playSound(null, pos, CaffeinatedSoundEvents.BLOCK_CAULDRON_CAMPFIRE_BREW, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.updateListeners(pos, state, state, Block.NOTIFY_ALL); + world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(state)); + } + CauldronCampfireBlockEntity.markDirty(world, pos, state); + } } public static void clientTick(World world, BlockPos pos, BlockState state, CauldronCampfireBlockEntity cauldronCampfire) { Random random = world.getRandom(); - int i; if (random.nextFloat() < 0.06F) { - for(i = 0; i < random.nextInt(2) + 2; ++i) { + for (int i = 0; i < random.nextInt(2) + 2; i++) { CauldronCampfireBlock.spawnSmokeParticle(world, pos, false); } } + + if (state.get(CauldronCampfireBlock.FILLED)) { + boolean bl = cauldronCampfire.hasReagent(); + if (bl) { + float f = random.nextFloat() * MathHelper.PI * 2.0F; + world.addParticle(ParticleTypes.SMOKE, pos.getX() + 0.5 + MathHelper.sin(f) * 0.45, pos.getY() + random.nextBetween(6, 8) / 16.0, pos.getZ() + 0.5 + MathHelper.cos(f) * 0.45, 0.0, 5.0E-4, 0.0); + } + + if (random.nextInt(50) == 0) { + world.playSoundAtBlockCenter(pos, CaffeinatedSoundEvents.BLOCK_CAULDRON_CAMPFIRE_BUBBLE, SoundCategory.BLOCKS, bl ? 0.2F : 0.1F, bl ? 1.0F : 2.0F, false); + } + } + } + + @Override + public void readNbt(NbtCompound nbt) { + super.readNbt(nbt); + this.inventory.clear(); + Inventories.readNbt(nbt, this.inventory); + this.brewingTime = nbt.getInt("BrewingTime"); + this.brewingTimeTotal = nbt.getInt("BrewingTimeTotal"); + } + + @Override + protected void writeNbt(NbtCompound nbt) { + super.writeNbt(nbt); + Inventories.writeNbt(nbt, this.inventory, true); + nbt.putInt("BrewingTime", this.brewingTime); + nbt.putInt("BrewingTimeTotal", this.brewingTimeTotal); + } + + @Override + public Packet toUpdatePacket() { + return BlockEntityUpdateS2CPacket.create(this); + } + + @Override + public NbtCompound toInitialChunkDataNbt() { + NbtCompound nbtCompound = new NbtCompound(); + Inventories.writeNbt(nbtCompound, this.inventory, true); + return nbtCompound; + } + + public ItemStack getStack(int slot) { + return slot >= 0 && slot < this.inventory.size() ? this.inventory.get(slot) : ItemStack.EMPTY; + } + + private void setStack(int slot, ItemStack stack) { + if (slot >= 0 && slot < this.inventory.size()) { + this.inventory.set(slot, stack); + if (slot == 0) { + BlockState state = this.getWorld().getBlockState(this.getPos()); + if (state.get(CauldronCampfireBlock.FILLED) == stack.isEmpty()) { + this.getWorld().setBlockState(this.getPos(), state.with(CauldronCampfireBlock.FILLED, !stack.isEmpty())); + } + } + } + } + + public void addBaseIngredient(@Nullable Entity user, ItemStack stack) { + this.clear(); + this.brewingTime = 0; + this.setStack(0, stack.copyWithCount(1)); + this.getWorld().emitGameEvent(GameEvent.BLOCK_CHANGE, this.getPos(), GameEvent.Emitter.of(user, this.getCachedState())); + this.updateListeners(); + } + + public void addReagent(@Nullable Entity user, ItemStack stack) { + this.setStack(1, stack.copyWithCount(1)); + this.getWorld().emitGameEvent(GameEvent.BLOCK_CHANGE, this.getPos(), GameEvent.Emitter.of(user, this.getCachedState())); + this.updateListeners(); + } + + public static boolean isBaseIngredient(ItemStack stack) { + return PotionUtil.getPotion(stack) == Potions.WATER || stack.isOf(CaffeinatedItems.COFFEE_BOTTLE); + } + + public static boolean canBrewTogether(ItemStack stack, ItemStack stack2) { + return PotionUtil.getPotion(stack) == Potions.WATER && stack2.isOf(CaffeinatedItems.GROUND_COFFEE); + } + + public boolean hasReagent() { + return !this.getStack(1).isEmpty(); + } + + public int getColor() { + if (this.getStack(0).isOf(Items.POTION)) { + return BiomeColors.getWaterColor(this.getWorld(), this.getPos()); + } + if (this.getStack(0).isOf(CaffeinatedItems.COFFEE_BOTTLE)) { + return 0x4A2E20; + } + return -1; + } + + private void updateListeners() { + this.markDirty(); + this.getWorld().updateListeners(this.getPos(), this.getCachedState(), this.getCachedState(), Block.NOTIFY_ALL); + } + + public void clear() { + this.inventory.clear(); + BlockState state = this.getWorld().getBlockState(this.getPos()); + if (state.get(CauldronCampfireBlock.FILLED)) { + this.getWorld().setBlockState(this.getPos(), state.with(CauldronCampfireBlock.FILLED, false)); + } } } diff --git a/src/main/java/com/chikoritalover/caffeinated/mixin/ItemMixin.java b/src/main/java/com/chikoritalover/caffeinated/mixin/ItemMixin.java index d0217f6..bdfd303 100644 --- a/src/main/java/com/chikoritalover/caffeinated/mixin/ItemMixin.java +++ b/src/main/java/com/chikoritalover/caffeinated/mixin/ItemMixin.java @@ -7,14 +7,33 @@ import net.minecraft.entity.effect.StatusEffects; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Item.class) -public class ItemMixin { +public abstract class ItemMixin { + @Shadow + public abstract Item asItem(); + + @Inject(method = "getRecipeRemainder", at = @At("RETURN"), cancellable = true) + public void getRecipeRemainder(CallbackInfoReturnable cir) { + if (this.asItem() == Items.POTION) { + cir.setReturnValue(Items.GLASS_BOTTLE); + } + } + + @Inject(method = "hasRecipeRemainder", at = @At("RETURN"), cancellable = true) + public void hasRecipeRemainder(CallbackInfoReturnable cir) { + if (this.asItem() == Items.POTION) { + cir.setReturnValue(true); + } + } + @Inject(method = "finishUsing", at = @At(value = "HEAD")) public void finishUsing(ItemStack stack, World world, LivingEntity user, CallbackInfoReturnable info) { if (stack.isIn(CaffeinatedItemTags.COFFEE_FOOD) && user.getType().isIn(CaffeinatedEntityTypeTags.COFFEE_INFLICTS_POISON)) { diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedSoundEvents.java b/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedSoundEvents.java index d294b07..ce29475 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedSoundEvents.java +++ b/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedSoundEvents.java @@ -7,8 +7,8 @@ import net.minecraft.util.Identifier; public class CaffeinatedSoundEvents { - public static final SoundEvent BLOCK_CAULDRON_BREW = register("block.cauldron.brew"); - public static final SoundEvent BLOCK_CAULDRON_BUBBLE = register("block.cauldron.bubble"); + public static final SoundEvent BLOCK_CAULDRON_CAMPFIRE_BREW = register("block.cauldron_campfire.brew"); + public static final SoundEvent BLOCK_CAULDRON_CAMPFIRE_BUBBLE = register("block.cauldron_campfire.bubble"); public static final SoundEvent BLOCK_COFFEE_BEAN_BLOCK_BREAK = register("block.coffee_bean_block.break"); public static final SoundEvent BLOCK_COFFEE_BEAN_BLOCK_FALL = register("block.coffee_bean_block.fall"); diff --git a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedStats.java b/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedStats.java index 703da4b..42e15f3 100644 --- a/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedStats.java +++ b/src/main/java/com/chikoritalover/caffeinated/registry/CaffeinatedStats.java @@ -10,6 +10,7 @@ public class CaffeinatedStats { public static final Identifier COFFEE_TAKEN = register("coffee_taken", StatFormatter.DEFAULT); public static final Identifier EAT_TIRAMISU_SLICE = register("eat_tiramisu_slice", StatFormatter.DEFAULT); + public static final Identifier INTERACT_WITH_CAULDRON_CAMPFIRE = register("interact_with_cauldron_campfire", StatFormatter.DEFAULT); private static Identifier register(String id, StatFormatter formatter) { Identifier identifier = new Identifier(Caffeinated.MODID, id); diff --git a/src/main/resources/assets/caffeinated/lang/en_us.json b/src/main/resources/assets/caffeinated/lang/en_us.json index f33cb58..3396045 100644 --- a/src/main/resources/assets/caffeinated/lang/en_us.json +++ b/src/main/resources/assets/caffeinated/lang/en_us.json @@ -1,6 +1,6 @@ { "advancements.husbandry.brew_coffee.title": "Wake Up and Smell the Coffee", - "advancements.husbandry.brew_coffee.description": "Brew coffee in a Cauldron over a Campfire", + "advancements.husbandry.brew_coffee.description": "Add Ground Coffee to Water in a Campfire with Cauldron to brew Coffee", "advancements.husbandry.eat_tiramisu.title": "I Tira-Miss-U", "advancements.husbandry.eat_tiramisu.description": "Bake and take a bite of a Tiramisu", @@ -45,11 +45,12 @@ "itemGroup.caffeinated.caffeinated": "Caffeinated", - "subtitles.block.cauldron.brew": "Cauldron brews", - "subtitles.block.cauldron.bubble": "Cauldron bubbles", + "subtitles.block.cauldron_campfire.brew": "Cauldron brews", + "subtitles.block.cauldron_campfire.bubble": "Cauldron bubbles", "subtitles.item.coffee_bottle.drink": "Slurping", "subtitles.item.ground_coffee.splash": "Ground Coffee splashes", "stat.caffeinated.coffee_taken": "Coffee Taken from Cauldron", - "stat.caffeinated.eat_tiramisu_slice": "Tiramisu Slices Eaten" + "stat.caffeinated.eat_tiramisu_slice": "Tiramisu Slices Eaten", + "stat.caffeinated.interact_with_cauldron_campfire": "Interactions with Campfire with Cauldron" } \ No newline at end of file diff --git a/src/main/resources/assets/caffeinated/models/block/cauldron_campfire_off.json b/src/main/resources/assets/caffeinated/models/block/cauldron_campfire_off.json index 2f12bc2..c272fe9 100644 --- a/src/main/resources/assets/caffeinated/models/block/cauldron_campfire_off.json +++ b/src/main/resources/assets/caffeinated/models/block/cauldron_campfire_off.json @@ -67,7 +67,7 @@ }, { "from": [2, 5, 2], - "to": [14, 16, 14], + "to": [14, 15.99, 14], "faces": { "north": {"uv": [0, 0, 12, 11], "texture": "#cauldron_side"}, "east": {"uv": [0, 0, 12, 11], "texture": "#cauldron_side"}, diff --git a/src/main/resources/assets/caffeinated/models/block/cauldron_campfire_off_filled.json b/src/main/resources/assets/caffeinated/models/block/cauldron_campfire_off_filled.json new file mode 100644 index 0000000..3f60dd1 --- /dev/null +++ b/src/main/resources/assets/caffeinated/models/block/cauldron_campfire_off_filled.json @@ -0,0 +1,89 @@ +{ + "parent": "block/block", + "textures": { + "particle": "block/campfire_log", + "log": "block/campfire_log", + "cauldron_side": "caffeinated:block/cauldron_campfire_side", + "cauldron_top": "caffeinated:block/cauldron_campfire_top", + "liquid": "block/water_still" + }, + "elements": [ + { + "from": [1, 0, 0], + "to": [5, 4, 16], + "faces": { + "north": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "north"}, + "east": {"uv": [0, 1, 16, 5], "texture": "#log"}, + "south": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "south"}, + "west": {"uv": [16, 0, 0, 4], "texture": "#log"}, + "up": {"uv": [0, 0, 16, 4], "rotation": 90, "texture": "#log"}, + "down": {"uv": [0, 0, 16, 4], "rotation": 90, "texture": "#log", "cullface": "down"} + } + }, + { + "from": [0, 3, 11], + "to": [16, 7, 15], + "faces": { + "north": {"uv": [16, 0, 0, 4], "texture": "#log"}, + "east": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "east"}, + "south": {"uv": [0, 0, 16, 4], "texture": "#log"}, + "west": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "west"}, + "up": {"uv": [0, 0, 16, 4], "rotation": 180, "texture": "#log"}, + "down": {"uv": [0, 4, 16, 8], "texture": "#log"} + } + }, + { + "from": [11, 0, 0], + "to": [15, 4, 16], + "faces": { + "north": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "north"}, + "east": {"uv": [0, 0, 16, 4], "texture": "#log"}, + "south": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "south"}, + "west": {"uv": [16, 1, 0, 5], "texture": "#log"}, + "up": {"uv": [0, 0, 16, 4], "rotation": 90, "texture": "#log"}, + "down": {"uv": [0, 0, 16, 4], "rotation": 90, "texture": "#log", "cullface": "down"} + } + }, + { + "from": [0, 3, 1], + "to": [16, 7, 5], + "faces": { + "north": {"uv": [0, 0, 16, 4], "texture": "#log"}, + "east": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "east"}, + "south": {"uv": [16, 0, 0, 4], "texture": "#log"}, + "west": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "west"}, + "up": {"uv": [0, 0, 16, 4], "rotation": 180, "texture": "#log"}, + "down": {"uv": [0, 4, 16, 8], "texture": "#log"} + } + }, + { + "from": [5, 0, 0], + "to": [11, 1, 16], + "faces": { + "north": {"uv": [0, 15, 6, 16], "texture": "#log", "cullface": "north"}, + "south": {"uv": [10, 15, 16, 16], "texture": "#log", "cullface": "south"}, + "up": {"uv": [0, 8, 16, 14], "rotation": 90, "texture": "#log"}, + "down": {"uv": [0, 8, 16, 14], "rotation": 90, "texture": "#log", "cullface": "down"} + } + }, + { + "from": [2, 5, 2], + "to": [14, 15.99, 14], + "faces": { + "north": {"uv": [0, 0, 12, 11], "texture": "#cauldron_side"}, + "east": {"uv": [0, 0, 12, 11], "texture": "#cauldron_side"}, + "south": {"uv": [0, 0, 12, 11], "texture": "#cauldron_side"}, + "west": {"uv": [0, 0, 12, 11], "texture": "#cauldron_side"}, + "up": {"uv": [0, 0, 12, 12], "texture": "#cauldron_top"}, + "down": {"uv": [0, 0, 12, 12], "texture": "#cauldron_side"} + } + }, + { + "from": [4, 16, 4], + "to": [12, 16, 12], + "faces": { + "up": {"uv": [4, 4, 12, 12], "texture": "#liquid", "tintindex": 0} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/caffeinated/models/block/template_cauldron_campfire.json b/src/main/resources/assets/caffeinated/models/block/template_cauldron_campfire.json index 3ad791a..34b0524 100644 --- a/src/main/resources/assets/caffeinated/models/block/template_cauldron_campfire.json +++ b/src/main/resources/assets/caffeinated/models/block/template_cauldron_campfire.json @@ -87,7 +87,7 @@ }, { "from": [2, 5, 2], - "to": [14, 16, 14], + "to": [14, 15.99, 14], "faces": { "north": {"uv": [0, 0, 12, 11], "texture": "#cauldron_side"}, "east": {"uv": [0, 0, 12, 11], "texture": "#cauldron_side"}, diff --git a/src/main/resources/assets/caffeinated/models/block/template_cauldron_campfire_filled.json b/src/main/resources/assets/caffeinated/models/block/template_cauldron_campfire_filled.json new file mode 100644 index 0000000..8d4e1c0 --- /dev/null +++ b/src/main/resources/assets/caffeinated/models/block/template_cauldron_campfire_filled.json @@ -0,0 +1,109 @@ +{ + "parent": "block/block", + "textures": { + "particle": "block/campfire_log", + "log": "block/campfire_log", + "cauldron_side": "caffeinated:block/cauldron_campfire_side", + "cauldron_top": "caffeinated:block/cauldron_campfire_top", + "liquid": "block/water_still" + }, + "elements": [ + { + "from": [1, 0, 0], + "to": [5, 4, 16], + "faces": { + "north": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "north"}, + "east": {"uv": [0, 1, 16, 5], "texture": "#lit_log"}, + "south": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "south"}, + "west": {"uv": [16, 0, 0, 4], "texture": "#log"}, + "up": {"uv": [0, 0, 16, 4], "rotation": 90, "texture": "#log"}, + "down": {"uv": [0, 0, 16, 4], "rotation": 90, "texture": "#log", "cullface": "down"} + } + }, + { + "from": [0, 3, 11], + "to": [16, 7, 15], + "faces": { + "north": {"uv": [16, 0, 0, 4], "texture": "#lit_log"}, + "east": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "east"}, + "south": {"uv": [0, 0, 16, 4], "texture": "#lit_log"}, + "west": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "west"}, + "up": {"uv": [0, 0, 16, 4], "rotation": 180, "texture": "#log"}, + "down": {"uv": [0, 4, 16, 8], "texture": "#lit_log"} + } + }, + { + "from": [11, 0, 0], + "to": [15, 4, 16], + "faces": { + "north": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "north"}, + "east": {"uv": [0, 0, 16, 4], "texture": "#log"}, + "south": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "south"}, + "west": {"uv": [16, 1, 0, 5], "texture": "#lit_log"}, + "up": {"uv": [0, 0, 16, 4], "rotation": 90, "texture": "#log"}, + "down": {"uv": [0, 0, 16, 4], "rotation": 90, "texture": "#log", "cullface": "down"} + } + }, + { + "from": [0, 3, 1], + "to": [16, 7, 5], + "faces": { + "north": {"uv": [0, 0, 16, 4], "texture": "#lit_log"}, + "east": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "east"}, + "south": {"uv": [16, 0, 0, 4], "texture": "#lit_log"}, + "west": {"uv": [0, 4, 4, 8], "texture": "#log", "cullface": "west"}, + "up": {"uv": [0, 0, 16, 4], "rotation": 180, "texture": "#log"}, + "down": {"uv": [0, 4, 16, 8], "texture": "#lit_log"} + } + }, + { + "from": [5, 0, 0], + "to": [11, 1, 16], + "faces": { + "north": {"uv": [0, 15, 6, 16], "texture": "#log", "cullface": "north"}, + "south": {"uv": [10, 15, 16, 16], "texture": "#log", "cullface": "south"}, + "up": {"uv": [0, 8, 16, 14], "rotation": 90, "texture": "#lit_log"}, + "down": {"uv": [0, 8, 16, 14], "rotation": 90, "texture": "#log", "cullface": "down"} + } + }, + { + "from": [0.8, 1, 8], + "to": [15.2, 7, 8], + "shade": false, + "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8], "rescale": true}, + "faces": { + "north": {"uv": [0, 10, 16, 16], "texture": "#fire"}, + "south": {"uv": [0, 10, 16, 16], "texture": "#fire"} + } + }, + { + "from": [8, 1, 0.8], + "to": [8, 7, 15.2], + "shade": false, + "rotation": {"angle": 45, "axis": "y", "origin": [8, 8, 8], "rescale": true}, + "faces": { + "east": {"uv": [0, 10, 16, 16], "texture": "#fire"}, + "west": {"uv": [0, 10, 16, 16], "texture": "#fire"} + } + }, + { + "from": [2, 5, 2], + "to": [14, 15.99, 14], + "faces": { + "north": {"uv": [0, 0, 12, 11], "texture": "#cauldron_side"}, + "east": {"uv": [0, 0, 12, 11], "texture": "#cauldron_side"}, + "south": {"uv": [0, 0, 12, 11], "texture": "#cauldron_side"}, + "west": {"uv": [0, 0, 12, 11], "texture": "#cauldron_side"}, + "up": {"uv": [0, 0, 12, 12], "texture": "#cauldron_top"}, + "down": {"uv": [0, 0, 12, 12], "texture": "#cauldron_side"} + } + }, + { + "from": [4, 16, 4], + "to": [12, 16, 12], + "faces": { + "up": {"uv": [4, 4, 12, 12], "texture": "#liquid", "tintindex": 0} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/caffeinated/sounds.json b/src/main/resources/assets/caffeinated/sounds.json index e12adaf..f46650e 100644 --- a/src/main/resources/assets/caffeinated/sounds.json +++ b/src/main/resources/assets/caffeinated/sounds.json @@ -1,16 +1,16 @@ { - "block.cauldron.brew": { - "subtitle": "subtitles.block.cauldron.brew", + "block.cauldron_campfire.brew": { + "subtitle": "subtitles.block.cauldron_campfire.brew", "sounds": [ "minecraft:block/brewing_stand/brew1", "minecraft:block/brewing_stand/brew2" ] }, - "block.cauldron.bubble": { - "subtitle": "subtitles.block.cauldron.bubble", + "block.cauldron_campfire.bubble": { + "subtitle": "subtitles.block.cauldron_campfire.bubble", "sounds": [ - "caffeinated:block/cauldron/bubble1", - "caffeinated:block/cauldron/bubble2" + "caffeinated:block/cauldron_campfire/bubble1", + "caffeinated:block/cauldron_campfire/bubble2" ] }, "block.coffee_bean_block.break": { diff --git a/src/main/resources/assets/caffeinated/sounds/block/cauldron/bubble1.ogg b/src/main/resources/assets/caffeinated/sounds/block/cauldron_campfire/bubble1.ogg similarity index 100% rename from src/main/resources/assets/caffeinated/sounds/block/cauldron/bubble1.ogg rename to src/main/resources/assets/caffeinated/sounds/block/cauldron_campfire/bubble1.ogg diff --git a/src/main/resources/assets/caffeinated/sounds/block/cauldron/bubble2.ogg b/src/main/resources/assets/caffeinated/sounds/block/cauldron_campfire/bubble2.ogg similarity index 100% rename from src/main/resources/assets/caffeinated/sounds/block/cauldron/bubble2.ogg rename to src/main/resources/assets/caffeinated/sounds/block/cauldron_campfire/bubble2.ogg diff --git a/src/main/resources/assets/caffeinated/textures/block/cauldron_campfire_top.png b/src/main/resources/assets/caffeinated/textures/block/cauldron_campfire_top.png index c5e5e30..4252482 100644 Binary files a/src/main/resources/assets/caffeinated/textures/block/cauldron_campfire_top.png and b/src/main/resources/assets/caffeinated/textures/block/cauldron_campfire_top.png differ diff --git a/src/main/resources/data/caffeinated/advancements/husbandry/brew_coffee.json b/src/main/resources/data/caffeinated/advancements/husbandry/brew_coffee.json index b6cc79d..47c3f42 100644 --- a/src/main/resources/data/caffeinated/advancements/husbandry/brew_coffee.json +++ b/src/main/resources/data/caffeinated/advancements/husbandry/brew_coffee.json @@ -17,33 +17,13 @@ "parent": "minecraft:husbandry/root", "criteria": { "brew_coffee": { - "trigger": "minecraft:item_used_on_block", + "trigger": "caffeinated:brew_coffee", "conditions": { "item": { "items": [ - "minecraft:glass_bottle" + "caffeinated:coffee_bottle" ] - }, - "location": [ - { - "condition": "minecraft:location_check", - "predicate": { - "block": { - "blocks": [ - "caffeinated:coffee_cauldron" - ] - } - } - }, - { - "condition": "minecraft:match_tool", - "predicate": { - "items": [ - "minecraft:glass_bottle" - ] - } - } - ] + } } } },