Skip to content

Commit

Permalink
-Added links and unfinished chemistry stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Cassunshine committed Feb 13, 2024
1 parent 54ce8f0 commit d263b4c
Show file tree
Hide file tree
Showing 64 changed files with 1,540 additions and 206 deletions.
10 changes: 7 additions & 3 deletions src/client/java/cassunshine/thework/TheWorkClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import cassunshine.thework.blocks.TheWorkBlocks;
import cassunshine.thework.client.networking.TheWorkClientNetworking;
import cassunshine.thework.particles.TheWorkParticles;
import cassunshine.thework.rendering.blockentities.TheWorkBlockEntityRenderers;
import cassunshine.thework.rendering.blockentities.alchemy_block.nodes.AlchemyNodeTypeRenderers;
import cassunshine.thework.rendering.entities.TheWorkEntityRenderers;
import cassunshine.thework.rendering.model.TheWorkModelPlugin;
import cassunshine.thework.rendering.particles.TheWorkParticleRenderers;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.RenderLayer;
import org.slf4j.Logger;
Expand All @@ -32,6 +31,9 @@ public void onInitializeClient() {

TheWorkClientNetworking.initialize();
BlockRenderLayerMap.INSTANCE.putBlock(TheWorkBlocks.ALCHEMY_JAR_BLOCK, RenderLayer.getTranslucent());


ModelLoadingPlugin.register(new TheWorkModelPlugin());
}

public static double getTime() {
Expand All @@ -41,4 +43,6 @@ public static double getTime() {
return 0;
return (world.getTime() + MinecraftClient.getInstance().getTickDelta()) / 20.0f;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import cassunshine.thework.blockentities.TheWorkBlockEntities;
import cassunshine.thework.rendering.blockentities.alchemy_block.AlchemyCircleBlockEntityRenderer;
import cassunshine.thework.rendering.blockentities.chemistry.ChemistrySetBlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactories;

public class TheWorkBlockEntityRenderers {

public static void initialize() {
BlockEntityRendererFactories.register(TheWorkBlockEntities.ALCHEMY_CIRCLE_TYPE, AlchemyCircleBlockEntityRenderer::new);
BlockEntityRendererFactories.register(TheWorkBlockEntities.CHEMISTRY_SET_TYPE, ChemistrySetBlockEntityRenderer::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import cassunshine.thework.alchemy.circle.AlchemyCircle;
import cassunshine.thework.alchemy.circle.node.AlchemyNode;
import cassunshine.thework.alchemy.circle.node.type.AlchemyNodeTypes;
import cassunshine.thework.alchemy.circle.path.AlchemyLink;
import cassunshine.thework.alchemy.circle.ring.AlchemyRing;
import cassunshine.thework.blockentities.alchemycircle.AlchemyCircleBlockEntity;
import cassunshine.thework.blocks.TheWorkBlocks;
Expand All @@ -20,7 +21,9 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.BlockItem;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;

import java.util.ArrayList;
import java.util.Random;
Expand Down Expand Up @@ -100,6 +103,9 @@ public void render(AlchemyCircleBlockEntity entity, float tickDelta, MatrixStack
drawRing(ring, null);
}

for (AlchemyLink link : circle.links)
drawLink(circle, link);

for (AlchemyNode node : specialRenders) {
drawNode(node);
}
Expand Down Expand Up @@ -172,6 +178,33 @@ private void drawNode(AlchemyNode node) {
RenderingUtilities.popMat();
}

private void drawLink(AlchemyCircle circle, AlchemyLink link) {
Vec3d sourcePosition = link.sourceNode.getPosition().withAxis(Direction.Axis.Y, circle.blockEntity.getPos().getY());
Vec3d destinationPosition = link.destinationNode.getPosition().withAxis(Direction.Axis.Y, circle.blockEntity.getPos().getY());

sourcePosition = sourcePosition.subtract(circle.blockEntity.fullPosition);
destinationPosition = destinationPosition.subtract(circle.blockEntity.fullPosition);

var delta = destinationPosition.subtract(sourcePosition);

float angle = (float)MathHelper.atan2(-delta.z, delta.x);
angle += MathHelper.PI * 0.5f;

RenderingUtilities.pushMat();
RenderingUtilities.translateMatrix(sourcePosition.x, 0, sourcePosition.z);
RenderingUtilities.rotateMatrix(0, angle, 0);

if(link.sourceNode.nodeType != AlchemyNodeTypes.NONE)
RenderingUtilities.translateMatrix(0, 0, 0.5f);

RenderingUtilities.saneVertex(-HALF_LINE_THICKNESS, 0, 0, 0, 0);
RenderingUtilities.saneVertex(HALF_LINE_THICKNESS, 0, 0, 0, 0);
RenderingUtilities.saneVertex(HALF_LINE_THICKNESS, 0, link.length, 0, 0);
RenderingUtilities.saneVertex(-HALF_LINE_THICKNESS, 0, link.length, 0, 0);

RenderingUtilities.popMat();
}

private void drawFullCircle(float radius, int segments) {
float circleMin = radius;
float circleMax = radius - LINE_THICKNESS;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cassunshine.thework.rendering.blockentities.chemistry;

import cassunshine.thework.blockentities.chemistry.ChemistrySetBlockEntity;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;

public class ChemistrySetBlockEntityRenderer implements BlockEntityRenderer<ChemistrySetBlockEntity> {

public ChemistrySetBlockEntityRenderer(BlockEntityRendererFactory.Context context) {

}

@Override
public void render(ChemistrySetBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package cassunshine.thework.rendering.model;

import cassunshine.thework.TheWorkMod;
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.*;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.BlockRenderView;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;

public class ChemistrySetModel implements UnbakedModel, BakedModel, FabricBakedModel {
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction face, Random random) {
return List.of();
}

@Override
public boolean useAmbientOcclusion() {
return true;
}

@Override
public boolean hasDepth() {
return false;
}

@Override
public boolean isSideLit() {
return false;
}

@Override
public boolean isBuiltin() {
return false;
}

@Override
public Sprite getParticleSprite() {
return null;
}

@Override
public ModelTransformation getTransformation() {
return null;
}

@Override
public ModelOverrideList getOverrides() {
return null;
}

@Override
public Collection<Identifier> getModelDependencies() {
return List.of(new Identifier(TheWorkMod.ModID, "block/evaporator"));
}

@Override
public void setParents(Function<Identifier, UnbakedModel> modelLoader) {

}

@Override
public boolean isVanillaAdapter() {
return false;
}

@Nullable
@Override
public BakedModel bake(Baker baker, Function<SpriteIdentifier, Sprite> textureGetter, ModelBakeSettings rotationContainer, Identifier modelId) {
return this;
}

@Override
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
TheWorkMod.LOGGER.error("BLEH");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cassunshine.thework.rendering.model;

import cassunshine.thework.TheWorkMod;
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;
import net.minecraft.util.Identifier;

public class TheWorkModelPlugin implements ModelLoadingPlugin {

public static final ChemistrySetModel CHEMISTRY_SET_MODEL = new ChemistrySetModel();
public static final Identifier CHEMISTRY_SET_MODEL_ID = new Identifier(TheWorkMod.ModID, "block/chemistry_set");

@Override
public void onInitializeModelLoader(Context pluginContext) {
/*pluginContext.modifyModelOnLoad().register((original, context) -> {
if (context.id().equals(CHEMISTRY_SET_MODEL_ID))
return CHEMISTRY_SET_MODEL;
return original;
});*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public static void saneVertex(float x, float y, float z, float u, float v) {
consumer.vertex(stack.peek().getPositionMatrix(), x + getWobble(), y, z + getWobble()).color(r, g, b, a).texture(u, v).overlay(overlay).light(light).normal(stack.peek().getNormalMatrix(), normalX, normalY, normalZ).next();
}

public static void saneVertex(double x, double y, double z, float u, float v) {
saneVertex((float) x, (float) y, (float) z, u, v);
}

public static void renderItem(ItemStack stack, World world, int light, int overlay) {
if (stack.isEmpty())
return;
Expand All @@ -93,6 +97,10 @@ public static void popMat() {
public static void translateMatrix(float x, float y, float z) {
stack.translate(x, y, z);
}
public static void translateMatrix(double x, double y, double z) {
stack.translate(x, y, z);
}


public static void rotateMatrix(float x, float y, float z) {
stack.multiply(new Quaternionf().rotationX(x));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"" : {
"model" : "thework:block/chemistry_set"
}
}
}
113 changes: 113 additions & 0 deletions src/client/resources/assets/thework/models/block/evaporator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"credit": "Made with Blockbench",
"elements": [
{
"name": "bottle",
"from": [3, 2, 3],
"to": [13, 8, 13],
"color": 1,
"faces": {
"north": {"uv": [0, 0, 10, 6], "texture": "#missing"},
"east": {"uv": [0, 0, 10, 6], "texture": "#missing"},
"south": {"uv": [0, 0, 10, 6], "texture": "#missing"},
"west": {"uv": [0, 0, 10, 6], "texture": "#missing"},
"up": {"uv": [0, 0, 10, 10], "texture": "#missing"},
"down": {"uv": [0, 0, 10, 10], "texture": "#missing"}
}
},
{
"name": "tube 1",
"from": [7, 8, 7],
"to": [9, 12, 9],
"color": 3,
"faces": {
"north": {"uv": [0, 0, 2, 4], "texture": "#missing"},
"east": {"uv": [0, 0, 2, 4], "texture": "#missing"},
"south": {"uv": [0, 0, 2, 4], "texture": "#missing"},
"west": {"uv": [0, 0, 2, 4], "texture": "#missing"},
"up": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"down": {"uv": [0, 0, 2, 2], "texture": "#missing"}
}
},
{
"name": "tube 2",
"from": [0, 2, 7],
"to": [2, 10, 9],
"color": 3,
"faces": {
"north": {"uv": [0, 0, 2, 8], "texture": "#missing"},
"east": {"uv": [0, 0, 2, 8], "texture": "#missing"},
"south": {"uv": [0, 0, 2, 8], "texture": "#missing"},
"west": {"uv": [0, 0, 2, 8], "texture": "#missing"},
"up": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"down": {"uv": [0, 0, 2, 2], "texture": "#missing"}
}
},
{
"name": "tube 2",
"from": [0, 10, 7],
"to": [7, 12, 9],
"color": 3,
"faces": {
"north": {"uv": [0, 0, 7, 2], "texture": "#missing"},
"east": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"south": {"uv": [0, 0, 7, 2], "texture": "#missing"},
"west": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"up": {"uv": [0, 0, 7, 2], "texture": "#missing"},
"down": {"uv": [0, 0, 7, 2], "texture": "#missing"}
}
},
{
"from": [3, 0, 3],
"to": [5, 2, 5],
"color": 3,
"faces": {
"north": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"east": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"south": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"west": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"up": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"down": {"uv": [0, 0, 2, 2], "texture": "#missing"}
}
},
{
"from": [11, 0, 3],
"to": [13, 2, 5],
"color": 3,
"faces": {
"north": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"east": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"south": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"west": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"up": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"down": {"uv": [0, 0, 2, 2], "texture": "#missing"}
}
},
{
"from": [11, 0, 11],
"to": [13, 2, 13],
"color": 3,
"faces": {
"north": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"east": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"south": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"west": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"up": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"down": {"uv": [0, 0, 2, 2], "texture": "#missing"}
}
},
{
"from": [3, 0, 11],
"to": [5, 2, 13],
"color": 3,
"faces": {
"north": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"east": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"south": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"west": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"up": {"uv": [0, 0, 2, 2], "texture": "#missing"},
"down": {"uv": [0, 0, 2, 2], "texture": "#missing"}
}
}
]
}
Loading

0 comments on commit d263b4c

Please sign in to comment.