Skip to content

Commit

Permalink
Add floor and ceiling drawers
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiDragon committed Dec 10, 2023
1 parent 7048005 commit 44a425c
Show file tree
Hide file tree
Showing 46 changed files with 336 additions and 119 deletions.
4 changes: 3 additions & 1 deletion changelog/2.1.0+1.20.4.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
* Fix smart caching causing bluetooth storage and dupe bugs (maybe)
* Updated to 1.20.4
* Updated to 1.20.4
* Internal changes
* Added ability to place drawers on floor and ceiling
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.1

mod_version=2.0.9
mod_version=2.1.0
maven_group=io.github.mattidragon
archives_base_name=ExtendedDrawers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
public class ModMenuIntegration implements ModMenuApi {
@Override
public com.terraformersmc.modmenu.api.ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> ConfigScreenFactory.createScreen(parent, ExtendedDrawers.CONFIG.get(), config -> ExtendedDrawers.CONFIG.set(config));
return parent -> ConfigScreenFactory.createScreen(parent, ExtendedDrawers.CONFIG.get(), ExtendedDrawers.CONFIG::set);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.enums.BlockFace;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.DiffuseLighting;
Expand All @@ -24,7 +25,6 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.joml.Quaternionf;

Expand Down Expand Up @@ -144,9 +144,9 @@ public void renderItem(ItemVariant item, boolean small, int light, MatrixStack m
} else {
// Stolen from storage drawers
if (model.isSideLit()) {
matrices.peek().getNormalMatrix().mul(new Matrix3f().set(ITEM_LIGHT_ROTATION_3D));
matrices.peek().getNormalMatrix().rotate(ITEM_LIGHT_ROTATION_3D);
} else {
matrices.peek().getNormalMatrix().mul(new Matrix3f().set(ITEM_LIGHT_ROTATION_FLAT));
matrices.peek().getNormalMatrix().rotate(ITEM_LIGHT_ROTATION_FLAT);
}
}

Expand Down Expand Up @@ -175,11 +175,19 @@ public void renderText(String amount, boolean small, int light, MatrixStack matr
matrices.pop();
}

protected void alignMatrices(MatrixStack matrices, Direction dir) {
var pos = dir.getUnitVector();
protected void alignMatrices(MatrixStack matrices, Direction dir, BlockFace face) {
var pos = switch (face) {
case FLOOR -> Direction.UP.getUnitVector();
case CEILING -> Direction.DOWN.getUnitVector();
default -> dir.getUnitVector();
};
matrices.translate(pos.x / 2 + 0.5, pos.y / 2 + 0.5, pos.z / 2 + 0.5);
matrices.multiply(dir.getRotationQuaternion());
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(-90));
matrices.multiplyPositionMatrix(new Matrix4f().rotation(dir.getRotationQuaternion()));
switch (face) {
case FLOOR -> matrices.multiplyPositionMatrix(new Matrix4f().rotation(RotationAxis.POSITIVE_X.rotationDegrees(-90)));
case CEILING -> matrices.multiplyPositionMatrix(new Matrix4f().rotation(RotationAxis.POSITIVE_X.rotationDegrees(90)));
}
matrices.multiplyPositionMatrix(new Matrix4f().rotation(RotationAxis.POSITIVE_X.rotationDegrees(-90)));
matrices.translate(0, 0, 0.01);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ public int getRenderDistance() {
@Override
public void render(CompactingDrawerBlockEntity drawer, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
var drawerPos = drawer.getPos();
var dir = drawer.getCachedState().get(StorageDrawerBlock.FACING);
var horizontalDir = drawer.getCachedState().get(StorageDrawerBlock.FACING);
var face = drawer.getCachedState().get(StorageDrawerBlock.FACE);
var dir = StorageDrawerBlock.getFront(drawer.getCachedState());
var world = drawer.getWorld();

if (!shouldRender(drawer, dir)) return;

matrices.push();
alignMatrices(matrices, dir);
alignMatrices(matrices, horizontalDir, face);

light = WorldRenderer.getLightmapCoordinates(Objects.requireNonNull(drawer.getWorld()), drawer.getPos().offset(dir));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ public int getRenderDistance() {

@Override
public void render(DrawerBlockEntity drawer, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
var dir = drawer.getCachedState().get(StorageDrawerBlock.FACING);
var horizontalDir = drawer.getCachedState().get(StorageDrawerBlock.FACING);
var face = drawer.getCachedState().get(StorageDrawerBlock.FACE);
var dir = StorageDrawerBlock.getFront(drawer.getCachedState());
var world = drawer.getWorld();

if (!shouldRender(drawer, dir)) return;

matrices.push();
alignMatrices(matrices, dir);
alignMatrices(matrices, horizontalDir, face);

light = WorldRenderer.getLightmapCoordinates(Objects.requireNonNull(drawer.getWorld()), drawer.getPos().offset(dir));
var slots = ((DrawerBlock)drawer.getCachedState().getBlock()).slots;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.github.mattidragon.extendeddrawers.ExtendedDrawers;
import io.github.mattidragon.extendeddrawers.block.ShadowDrawerBlock;
import io.github.mattidragon.extendeddrawers.block.entity.ShadowDrawerBlockEntity;
import net.minecraft.block.enums.BlockFace;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.WorldRenderer;
Expand Down Expand Up @@ -32,7 +33,7 @@ public void render(ShadowDrawerBlockEntity drawer, float tickDelta, MatrixStack
if (!shouldRender(drawer, dir)) return;

matrices.push();
alignMatrices(matrices, dir);
alignMatrices(matrices, dir, BlockFace.WALL);

light = WorldRenderer.getLightmapCoordinates(Objects.requireNonNull(drawer.getWorld()), drawer.getPos().offset(dir));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,58 @@
{
"variants": {
"facing=east": {
"face=ceiling,facing=east": {
"model": "extended_drawers:block/compacting_drawer",
"x": 90,
"y": 90
},
"facing=north": {
"model": "extended_drawers:block/compacting_drawer"
"face=ceiling,facing=north": {
"model": "extended_drawers:block/compacting_drawer",
"x": 90,
"y": 0
},
"face=ceiling,facing=south": {
"model": "extended_drawers:block/compacting_drawer",
"x": 90,
"y": 180
},
"face=ceiling,facing=west": {
"model": "extended_drawers:block/compacting_drawer",
"x": 90,
"y": 270
},
"face=floor,facing=east": {
"model": "extended_drawers:block/compacting_drawer",
"x": 270,
"y": 90
},
"face=floor,facing=north": {
"model": "extended_drawers:block/compacting_drawer",
"x": 270,
"y": 0
},
"face=floor,facing=south": {
"model": "extended_drawers:block/compacting_drawer",
"x": 270,
"y": 180
},
"face=floor,facing=west": {
"model": "extended_drawers:block/compacting_drawer",
"x": 270,
"y": 270
},
"face=wall,facing=east": {
"model": "extended_drawers:block/compacting_drawer",
"y": 90
},
"face=wall,facing=north": {
"model": "extended_drawers:block/compacting_drawer",
"y": 0
},
"facing=south": {
"face=wall,facing=south": {
"model": "extended_drawers:block/compacting_drawer",
"y": 180
},
"facing=west": {
"face=wall,facing=west": {
"model": "extended_drawers:block/compacting_drawer",
"y": 270
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,58 @@
{
"variants": {
"facing=east": {
"face=ceiling,facing=east": {
"model": "extended_drawers:block/double_drawer",
"x": 90,
"y": 90
},
"facing=north": {
"model": "extended_drawers:block/double_drawer"
"face=ceiling,facing=north": {
"model": "extended_drawers:block/double_drawer",
"x": 90,
"y": 0
},
"face=ceiling,facing=south": {
"model": "extended_drawers:block/double_drawer",
"x": 90,
"y": 180
},
"face=ceiling,facing=west": {
"model": "extended_drawers:block/double_drawer",
"x": 90,
"y": 270
},
"face=floor,facing=east": {
"model": "extended_drawers:block/double_drawer",
"x": 270,
"y": 90
},
"face=floor,facing=north": {
"model": "extended_drawers:block/double_drawer",
"x": 270,
"y": 0
},
"face=floor,facing=south": {
"model": "extended_drawers:block/double_drawer",
"x": 270,
"y": 180
},
"face=floor,facing=west": {
"model": "extended_drawers:block/double_drawer",
"x": 270,
"y": 270
},
"face=wall,facing=east": {
"model": "extended_drawers:block/double_drawer",
"y": 90
},
"face=wall,facing=north": {
"model": "extended_drawers:block/double_drawer",
"y": 0
},
"facing=south": {
"face=wall,facing=south": {
"model": "extended_drawers:block/double_drawer",
"y": 180
},
"facing=west": {
"face=wall,facing=west": {
"model": "extended_drawers:block/double_drawer",
"y": 270
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,58 @@
{
"variants": {
"facing=east": {
"face=ceiling,facing=east": {
"model": "extended_drawers:block/quad_drawer",
"x": 90,
"y": 90
},
"facing=north": {
"model": "extended_drawers:block/quad_drawer"
"face=ceiling,facing=north": {
"model": "extended_drawers:block/quad_drawer",
"x": 90,
"y": 0
},
"face=ceiling,facing=south": {
"model": "extended_drawers:block/quad_drawer",
"x": 90,
"y": 180
},
"face=ceiling,facing=west": {
"model": "extended_drawers:block/quad_drawer",
"x": 90,
"y": 270
},
"face=floor,facing=east": {
"model": "extended_drawers:block/quad_drawer",
"x": 270,
"y": 90
},
"face=floor,facing=north": {
"model": "extended_drawers:block/quad_drawer",
"x": 270,
"y": 0
},
"face=floor,facing=south": {
"model": "extended_drawers:block/quad_drawer",
"x": 270,
"y": 180
},
"face=floor,facing=west": {
"model": "extended_drawers:block/quad_drawer",
"x": 270,
"y": 270
},
"face=wall,facing=east": {
"model": "extended_drawers:block/quad_drawer",
"y": 90
},
"face=wall,facing=north": {
"model": "extended_drawers:block/quad_drawer",
"y": 0
},
"facing=south": {
"face=wall,facing=south": {
"model": "extended_drawers:block/quad_drawer",
"y": 180
},
"facing=west": {
"face=wall,facing=west": {
"model": "extended_drawers:block/quad_drawer",
"y": 270
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,58 @@
{
"variants": {
"facing=east": {
"face=ceiling,facing=east": {
"model": "extended_drawers:block/single_drawer",
"x": 90,
"y": 90
},
"facing=north": {
"model": "extended_drawers:block/single_drawer"
"face=ceiling,facing=north": {
"model": "extended_drawers:block/single_drawer",
"x": 90,
"y": 0
},
"face=ceiling,facing=south": {
"model": "extended_drawers:block/single_drawer",
"x": 90,
"y": 180
},
"face=ceiling,facing=west": {
"model": "extended_drawers:block/single_drawer",
"x": 90,
"y": 270
},
"face=floor,facing=east": {
"model": "extended_drawers:block/single_drawer",
"x": 270,
"y": 90
},
"face=floor,facing=north": {
"model": "extended_drawers:block/single_drawer",
"x": 270,
"y": 0
},
"face=floor,facing=south": {
"model": "extended_drawers:block/single_drawer",
"x": 270,
"y": 180
},
"face=floor,facing=west": {
"model": "extended_drawers:block/single_drawer",
"x": 270,
"y": 270
},
"face=wall,facing=east": {
"model": "extended_drawers:block/single_drawer",
"y": 90
},
"face=wall,facing=north": {
"model": "extended_drawers:block/single_drawer",
"y": 0
},
"facing=south": {
"face=wall,facing=south": {
"model": "extended_drawers:block/single_drawer",
"y": 180
},
"facing=west": {
"face=wall,facing=west": {
"model": "extended_drawers:block/single_drawer",
"y": 270
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@
"recipes": [
"extended_drawers:access_point"
]
},
"sends_telemetry_event": false
}
}
Loading

0 comments on commit 44a425c

Please sign in to comment.