Skip to content

Commit

Permalink
feat: add production model for sal ammoniac accumulator
Browse files Browse the repository at this point in the history
Closes #104
  • Loading branch information
klikli-dev committed Oct 10, 2023
1 parent 2d5a7d1 commit df3b5fd
Show file tree
Hide file tree
Showing 22 changed files with 262 additions and 112 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2023-08-09T10:41:17.2384965 Books: theurgy
// 1.20.1 2023-10-10T14:25:54.1601208 Books: theurgy
ead61475fc866f8eb903a6d99236808a0383fd5a data/theurgy/modonomicon/books/the_hermetica/book.json
6397585a0c454daf7ca44fdfcd96a0fe11081905 data/theurgy/modonomicon/books/the_hermetica/categories/getting_started.json
d4d2dff97b589c74c8cfed44677e9cf1707a99fd data/theurgy/modonomicon/books/the_hermetica/categories/mercury_flux.json
Expand Down Expand Up @@ -37,4 +37,4 @@ c5f51b786bfc5c7a7803362acde27cfba40b1107 data/theurgy/modonomicon/books/the_herm
d3b133f22a814c94248deec0e585fc9c43228179 data/theurgy/modonomicon/books/the_hermetica/entries/spagyrics/liquefaction_cauldron.json
331cba56f57b89d6ecbf894b01af825e50e108d9 data/theurgy/modonomicon/books/the_hermetica/entries/spagyrics/principles.json
385ca34ac424c982fe951a36bbf2063af212639b data/theurgy/modonomicon/books/the_hermetica/entries/spagyrics/pyromantic_brazier.json
8a14684d4563cf8f4ba7212e7f5b19fcc8e2db48 data/theurgy/modonomicon/books/the_hermetica/entries/spagyrics/solvents.json
b0c8a709513a45788fa9bed6ad1347cdb7c17ba3 data/theurgy/modonomicon/books/the_hermetica/entries/spagyrics/solvents.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2023-08-04T14:44:08.3581096 Block States: theurgy
// 1.20.1 2023-10-10T13:40:49.1227737 Block States: theurgy
ef875fc2604f4f19d7604536c66d3d2c26163879 assets/theurgy/blockstates/calcination_oven.json
35782a4ebfe09e4f246b30170c9cec57e31cdcee assets/theurgy/blockstates/caloric_flux_emitter.json
92ebf87f417e3426f30d3e42eeafd933e446eb23 assets/theurgy/blockstates/deepslate_sal_ammoniac_ore.json
Expand Down Expand Up @@ -26,7 +26,7 @@ c79ce877fb80454b4c5ea666bcc5584c881e8c11 assets/theurgy/models/block/liquefactio
b409c8a9f0cf680d9b409e9d9dcef1a73e9c0948 assets/theurgy/models/block/mercury_catalyst.json
52afb4cf68605f9a482f6332b02f523a81b74168 assets/theurgy/models/block/pyromantic_brazier.json
90588f4755497f3c8df737fd06b92d33ff4d0542 assets/theurgy/models/block/pyromantic_brazier_lit.json
3d636dd41003fc736ccdcfb3599acc337df2fcd3 assets/theurgy/models/block/sal_ammoniac_accumulator.json
c79ce877fb80454b4c5ea666bcc5584c881e8c11 assets/theurgy/models/block/sal_ammoniac_accumulator.json
1d93f7f921865f74ffbb18817595c1c1316d322d assets/theurgy/models/block/sal_ammoniac_ore.json
c79ce877fb80454b4c5ea666bcc5584c881e8c11 assets/theurgy/models/block/sal_ammoniac_tank.json
e0f7b66a84e6588f01abbbce75b1803ffe5d46e2 assets/theurgy/models/item/calcination_oven.json
Expand All @@ -40,6 +40,6 @@ e0f7b66a84e6588f01abbbce75b1803ffe5d46e2 assets/theurgy/models/item/incubator_su
7452e23d15a4905caefbd048ff18482ccaab75c2 assets/theurgy/models/item/liquefaction_cauldron.json
a3ce5b4c6144d76177427a7b1939fc3963811d05 assets/theurgy/models/item/mercury_catalyst.json
0040a92c6a948e59b36cb138ba297ede4435095c assets/theurgy/models/item/pyromantic_brazier.json
06b56e124d971cd220c73012c14b4d0adeb032d2 assets/theurgy/models/item/sal_ammoniac_accumulator.json
e0f7b66a84e6588f01abbbce75b1803ffe5d46e2 assets/theurgy/models/item/sal_ammoniac_accumulator.json
62725c755954bb986667238373b2f56bbcd0dfd4 assets/theurgy/models/item/sal_ammoniac_ore.json
e0f7b66a84e6588f01abbbce75b1803ffe5d46e2 assets/theurgy/models/item/sal_ammoniac_tank.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2023-08-09T10:53:29.7306597 Shaped Crafting Recipes
// 1.20.1 2023-10-10T14:33:00.2626773 Shaped Crafting Recipes
10616b9ecf4903d076f75f2b754a415125413d44 data/theurgy/recipes/crafting/shaped/amethyst_divination_rod.json
10238f21b147011c777703fc0ade32f5708fd6ad data/theurgy/recipes/crafting/shaped/calcination_oven.json
e31f43d1025bbbbe3ab7dbc9892e44cba7fdc0ab data/theurgy/recipes/crafting/shaped/caloric_flux_emitter_from_campfire.json
Expand All @@ -15,7 +15,7 @@ f2f5b3c943abc56b299522e13e48d9dd45cc608f data/theurgy/recipes/crafting/shaped/in
07f4c6dc7399b08687ef579a23091daaaeb481f7 data/theurgy/recipes/crafting/shaped/liquefaction_cauldron.json
fcb5ee591de6878bb39c43b57dc8357c2e8eff09 data/theurgy/recipes/crafting/shaped/mercury_catalyst.json
3c4bb4a4dd344b7d4cf2117d22125b0f47492423 data/theurgy/recipes/crafting/shaped/pyromantic_brazier.json
f227545084d653722a0d993c1b8ea7fb73447f12 data/theurgy/recipes/crafting/shaped/sal_ammoniac_accumulator.json
d936646ef1c9e9a146bf63b3676cc3e338c4f253 data/theurgy/recipes/crafting/shaped/sal_ammoniac_accumulator.json
a29b1881ae565d790b09ee568780627b7854e0fe data/theurgy/recipes/crafting/shaped/sal_ammoniac_tank.json
447b0ae8e48b94342498e573e74f31835a60a98f data/theurgy/recipes/crafting/shaped/sulfur_attuned_divination_rod_abundant.json
6300e5cdd6946b5b3c4e9b746ffe89201eb8e76b data/theurgy/recipes/crafting/shaped/sulfur_attuned_divination_rod_common.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.1 2023-08-09T18:51:43.5516968 Languages: en_us
7d945b41d6dfc83722dc10485c93b477893bf147 assets/theurgy/lang/en_us.json
// 1.20.1 2023-10-10T14:29:25.6583765 Languages: en_us
13c4aafac66d9901f8eb7b2f36e30ea04fc313a8 assets/theurgy/lang/en_us.json
4 changes: 2 additions & 2 deletions src/generated/resources/assets/theurgy/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
"book.theurgy.the_hermetica.spagyrics.pyromantic_brazier.name": "Pyromantic Brazier",
"book.theurgy.the_hermetica.spagyrics.pyromantic_brazier.usage.text": "Place the [](item://theurgy:pyromantic_brazier) below the Alchemical Device you want to power, then insert a fuel item by right-clicking the brazier with it.\n\\\n\\\nAlternatively a hopper can be used to insert fuel items.\n\\\n\\\nSee also [Alchemical Apparatus](entry://getting_started/apparatus_how_to).\n",
"book.theurgy.the_hermetica.spagyrics.pyromantic_brazier.usage.title": "Usage",
"book.theurgy.the_hermetica.spagyrics.solvents.crafting.text": "Sal Ammoniac is crafted in a [](item://theurgy:sal_ammoniac_accumulator). It has two modes of operation: It can increase the concentration of naturally occuring Sal Ammoniac in water to a usable level via evaporation, which is a rather slow and inefficient process, or it can enrich water with [Sal Ammoniac Crystals](item://theurgy:sal_ammoniac_crystal) to produce a usable solvent much quicker.\n",
"book.theurgy.the_hermetica.spagyrics.solvents.crafting.text": "Sal Ammoniac is crafted in a [](item://theurgy:sal_ammoniac_accumulator). It has two modes of operation: It can increase the concentration of naturally occurring Sal Ammoniac in water to a usable level via evaporation, which is a rather slow and inefficient process, or it can enrich water with [Sal Ammoniac Crystals](item://theurgy:sal_ammoniac_crystal) to produce a usable solvent much quicker.\n",
"book.theurgy.the_hermetica.spagyrics.solvents.crafting.title": "Crafting",
"book.theurgy.the_hermetica.spagyrics.solvents.description": "Solving all your problems?",
"book.theurgy.the_hermetica.spagyrics.solvents.intro.text": "Solvents are required for the process of Liquefaction, by which [#](ad03fc)Alchemical Sulfur[#]() is extracted from matter. Usually they are a type of acid. The following solvents are available:\n- Sal Ammoniac\n- Alkahest *(not yet implemented)*\n",
Expand All @@ -305,7 +305,7 @@
"book.theurgy.the_hermetica.spagyrics.solvents.sal_ammoniac_fluid_recipe.title.2": "... using Crystal",
"book.theurgy.the_hermetica.spagyrics.solvents.usage.text": "Place the [](item://theurgy:sal_ammoniac_accumulator) on top of a [](item://theurgy:sal_ammoniac_tank), and fill it with a Water by right-clicking with a water bucket.\n\\\n\\\nOptionally insert a [](item://theurgy:sal_ammoniac_crystal) by right-clicking the cauldron with it to speed up the process.\n\\\n\\\nSee also [Alchemical Apparatus](entry://getting_started/apparatus_how_to).\n",
"book.theurgy.the_hermetica.spagyrics.solvents.usage.title": "Usage",
"book.theurgy.the_hermetica.spagyrics.solvents.working.text": "If the [](item://theurgy:sal_ammoniac_accumulator) is working properly, it will show bubbles.\n",
"book.theurgy.the_hermetica.spagyrics.solvents.working.text": "If working properly, it will show blue or yellow (if using Sal Ammoniac Crystals) bubbles.\n",
"book.theurgy.the_hermetica.spagyrics.solvents.working.title": "Working Correctly",
"book.theurgy.the_hermetica.tooltip": "A treatise on the Ancient Art of Alchemy.\n§o(In-Game Guide for Theurgy)§r",
"config.jade.plugin_theurgy.mercury_flux": "Theurgy Mercury Flux",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"parent": "theurgy:block/sal_ammoniac_accumulator_template",
"ambientocclusion": false,
"textures": {
"particle": "minecraft:block/copper_block",
"texture": "theurgy:block/sal_ammoniac_accumulator"
"particle": "minecraft:block/copper_block"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"parent": "theurgy:block/sal_ammoniac_accumulator"
"parent": "minecraft:builtin/entity"
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"anchor": "",
"border": true,
"images": [
"theurgy:textures/gui/book/256.png"
"theurgy:textures/gui/book/sal_ammoniac_accumulator_working.png"
],
"text": "book.theurgy.the_hermetica.spagyrics.solvents.working.text",
"title": "book.theurgy.the_hermetica.spagyrics.solvents.working.title"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"key": {
"C": {
"tag": "forge:storage_blocks/copper"
},
"I": {
"tag": "forge:ingots/iron"
},
"R": {
"tag": "forge:rods/wooden"
},
"S": {
"tag": "forge:stone"
}
},
"pattern": [
"ICI",
"SIS",
"S S"
"SSS",
"III",
"R R"
],
"result": {
"count": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
Expand All @@ -24,10 +25,14 @@
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.items.wrapper.RecipeWrapper;
import org.jetbrains.annotations.Nullable;

public class SalAmmoniacAccumulatorBlock extends Block implements EntityBlock {

protected static final VoxelShape SHAPE = Block.box(1, 0, 1, 16, 6, 16);
protected ItemHandlerBehaviour itemHandlerBehaviour;
protected FluidHandlerBehaviour fluidHandlerBehaviour;

Expand All @@ -37,6 +42,12 @@ public SalAmmoniacAccumulatorBlock(Properties pProperties) {
this.fluidHandlerBehaviour = new OneTankFluidHandlerBehaviour();
}

@Override
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 13, 15);
return SHAPE;
}

@Override
@SuppressWarnings("deprecation")
public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@
import net.minecraftforge.items.ItemStackHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import software.bernie.geckolib.animatable.GeoBlockEntity;
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.core.animation.AnimatableManager;
import software.bernie.geckolib.util.GeckoLibUtil;

import java.util.function.Predicate;

public class SalAmmoniacAccumulatorBlockEntity extends BlockEntity {
public class SalAmmoniacAccumulatorBlockEntity extends BlockEntity implements GeoBlockEntity {

protected final AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this);

public ItemStackHandler inventory;
public LazyOptional<IItemHandler> inventoryCapability;
Expand All @@ -54,7 +60,7 @@ public SalAmmoniacAccumulatorBlockEntity(BlockPos pPos, BlockState pState) {
this.inventory = new Inventory();
this.inventoryCapability = LazyOptional.of(() -> this.inventory);

this.craftingBehaviour = new SalAmmoniacAccumulatorCraftingBehaviour(this, () -> this.inventory, () -> this.inventory, () -> this.waterTank, () -> this.getOutputTank());
this.craftingBehaviour = new SalAmmoniacAccumulatorCraftingBehaviour(this, () -> this.inventory, () -> this.inventory, () -> this.waterTank, this::getOutputTank);

this.waterTank = new WaterTank(FluidType.BUCKET_VOLUME * 10, this.craftingBehaviour::canProcess);
this.waterTankCapability = LazyOptional.of(() -> this.waterTank);
Expand Down Expand Up @@ -137,7 +143,7 @@ public void tickClient() {
var fluidHeight = fluidStack.getAmount() / (float) this.waterTank.getCapacity();

//move fluid plane between bottom and top of the model
fluidHeight += 0.5f;
fluidHeight += 0.3f;
fluidHeight *= 0.60f;

this.getLevel().addParticle(
Expand Down Expand Up @@ -213,6 +219,16 @@ public void load(CompoundTag pTag) {
this.craftingBehaviour.load(pTag);
}

@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) {

}

@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return this.animatableInstanceCache;
}

public class WaterTank extends FluidTank {

public WaterTank(int capacity, Predicate<FluidStack> validator) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-FileCopyrightText: 2023 klikli-dev
//
// SPDX-License-Identifier: MIT

package com.klikli_dev.theurgy.content.apparatus.salammoniacaccumulator;

import com.klikli_dev.theurgy.content.apparatus.salammoniacaccumulator.render.SalAmmoniacAccumulatorBEWLR;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import software.bernie.geckolib.animatable.GeoItem;
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.core.animation.AnimatableManager;
import software.bernie.geckolib.util.GeckoLibUtil;

import java.util.function.Consumer;

public class SalAmmoniacAccumulatorBlockItem extends BlockItem implements GeoItem {

private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);

public SalAmmoniacAccumulatorBlockItem(Block pBlock, Properties pProperties) {
super(pBlock, pProperties);
}


@Override
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
consumer.accept(new IClientItemExtensions() {
@Override
public BlockEntityWithoutLevelRenderer getCustomRenderer() {
return SalAmmoniacAccumulatorBEWLR.get();
}
});
}

@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) {
//do not show anims on item
}

@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return this.cache;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-FileCopyrightText: 2023 klikli-dev
//
// SPDX-License-Identifier: MIT

package com.klikli_dev.theurgy.content.apparatus.salammoniacaccumulator.render;

import com.klikli_dev.theurgy.content.apparatus.salammoniacaccumulator.SalAmmoniacAccumulatorBlockItem;
import com.klikli_dev.theurgy.content.apparatus.salammoniactank.SalAmmoniacTankBlockItem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.ItemTransform;
import net.minecraft.world.item.ItemDisplayContext;
import org.joml.Matrix4f;
import org.joml.Vector3f;
import software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.renderer.GeoItemRenderer;

public class SalAmmoniacAccumulatorBEWLR extends GeoItemRenderer<SalAmmoniacAccumulatorBlockItem> {

private static final SalAmmoniacAccumulatorBEWLR instance = new SalAmmoniacAccumulatorBEWLR();
private final ItemTransform transform;

public SalAmmoniacAccumulatorBEWLR() {
super(new SalAmmoniacAccumulatorModel());
this.withScale(0.5f);
this.transform = new ItemTransform(new Vector3f(30, 255, 0), new Vector3f(0, 0, 0), new Vector3f(1, 1, 1));
}

public static SalAmmoniacAccumulatorBEWLR get() {
return instance;
}

@Override
public void preRender(PoseStack poseStack, SalAmmoniacAccumulatorBlockItem animatable, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green, float blue,
float alpha) {
//copied from parent, but fixed to also center the model when scaling
this.itemRenderTranslations = new Matrix4f(poseStack.last().pose());

if (this.scaleWidth != 1 && this.scaleHeight != 1) {
poseStack.scale(this.scaleWidth, this.scaleHeight, this.scaleWidth);

//this is not as clean as I would like it - but it exactly centers the model for 0.5 scale :D
poseStack.translate(this.scaleWidth / 0.5 - 0.5, -0.1, this.scaleWidth / 0.5 - 0.5);
}

poseStack.translate(0.5f, 0.51f, 0.5f);

if (this.renderPerspective == ItemDisplayContext.GUI) {
this.transform.apply(false, poseStack);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-FileCopyrightText: 2023 klikli-dev
//
// SPDX-License-Identifier: MIT

package com.klikli_dev.theurgy.content.apparatus.salammoniacaccumulator.render;

import com.klikli_dev.theurgy.Theurgy;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import software.bernie.geckolib.core.animatable.GeoAnimatable;
import software.bernie.geckolib.model.GeoModel;

public class SalAmmoniacAccumulatorModel extends GeoModel {
@Override
public ResourceLocation getModelResource(GeoAnimatable animatable) {
return Theurgy.loc("geo/sal_ammoniac_accumulator.geo.json");
}

@Override
public ResourceLocation getTextureResource(GeoAnimatable animatable) {
return Theurgy.loc("textures/block/sal_ammoniac_accumulator.png");
}

@Override
public ResourceLocation getAnimationResource(GeoAnimatable animatable) {
return Theurgy.loc("");
}
}
Loading

0 comments on commit df3b5fd

Please sign in to comment.