Skip to content

Commit

Permalink
get minimal version of arch-ex 4.0 working
Browse files Browse the repository at this point in the history
  • Loading branch information
woodiertexas committed Jan 12, 2025
1 parent be9ed4c commit 5378442
Show file tree
Hide file tree
Showing 28 changed files with 258 additions and 344 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 4.0 Goals
- [ ] Use Debuggycore datagen when that's a thing
- [ ] Change modid to `arch_ex` (?)
- [ ] Change modid to `architecture_extensions` (?)
- [ ] Migrate over to Quilt Static Resources API when its a thing
- [ ] Use other Quilt APIs when appropriate (ex: Recipe API)
- [ ] Figure out the creative tab situation because currently, its a mess
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ loader_version=0.16.9
# Mod Properties
mod_version=4.0.0+mc1.20.1
maven_group=gay.debuggy
archives_base_name=arch_ex
archives_base_name=architecture_extensions

# Dependencies
fabric_version=0.92.3+1.20.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package gay.debuggy.architecture_extensions;

import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKey;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

import static gay.debuggy.architecture_extensions.ArchitectureExtensions.MOD_ID;
import static gay.debuggy.architecture_extensions.ArchitectureExtensionsBlocks.BIRCH_BEAM;

public class ArchExItemGroups {
public static RegistryKey<ItemGroup> makeItemGroupKey(String mod_id, String itemGroupPath) {
return RegistryKey.of(Registries.ITEM_GROUP.getKey(), new Identifier(mod_id, itemGroupPath));
}

public static final RegistryKey<ItemGroup> ARCH_EX_JSON_BLOCKS_KEY = makeItemGroupKey(MOD_ID, "json_blocks");
public static final RegistryKey<ItemGroup> ARCH_EX_GLTF_BLOCKS_KEY = makeItemGroupKey(MOD_ID, "gltf_blocks");

public static final ItemGroup ARCH_EX_JSON_BLOCKS = FabricItemGroup.builder()
.icon(() -> new ItemStack(BIRCH_BEAM))
.name(Text.of("Arch-Ex Building Blocks"))
.build();

public static final ItemGroup ARCH_EX_GLTF_BLOCKS = FabricItemGroup.builder()
.icon(() -> new ItemStack(Blocks.ACACIA_LEAVES))
.name(Text.of("Arch-Ex Building Blocks"))
.build();

public static void init() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package gay.debuggy.architecture_extensions;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;

import static gay.debuggy.architecture_extensions.ArchitectureExtensionsBlocks.BIRCH_BEAM;

public class ArchitectureExtensions implements ModInitializer {
public static final String MOD_ID = "architecture_extensions";

@Override
public void onInitialize() {
Registry.register(Registries.ITEM_GROUP, ArchExItemGroups.ARCH_EX_JSON_BLOCKS_KEY, ArchExItemGroups.ARCH_EX_JSON_BLOCKS);
Registry.register(Registries.ITEM_GROUP, ArchExItemGroups.ARCH_EX_GLTF_BLOCKS_KEY, ArchExItemGroups.ARCH_EX_GLTF_BLOCKS);

ItemGroupEvents.modifyEntriesEvent(ArchExItemGroups.ARCH_EX_JSON_BLOCKS_KEY).register(itemGroup -> {
itemGroup.addItem(BIRCH_BEAM);
});

ItemGroupEvents.modifyEntriesEvent(ArchExItemGroups.ARCH_EX_GLTF_BLOCKS_KEY).register(itemGroup -> {
itemGroup.addItem(BIRCH_BEAM);
});

ArchitectureExtensionsBlocks.init();
ArchExItemGroups.init();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package gay.debuggy.architecture_extensions;

import gay.debuggy.architecture_extensions.blocks.BeamBlock;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

public class ArchitectureExtensionsBlocks {
private static <T extends Block> T registerBlock(String path, T block) {
Registry.register(Registries.BLOCK, new Identifier(ArchitectureExtensions.MOD_ID, path), block);
Registry.register(Registries.ITEM, new Identifier(ArchitectureExtensions.MOD_ID, path), new BlockItem(block, new Item.Settings()));
return block;
}

public static final BeamBlock BIRCH_BEAM = registerBlock("birch_beam", new BeamBlock(FabricBlockSettings.copyOf(Blocks.BIRCH_LOG)));

public static void init() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package gay.debuggy.architecture_extensions.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.PillarBlock;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.Waterloggable;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.state.property.Property;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import org.joml.Vector3d;

public class BeamBlock extends PillarBlock implements Waterloggable {
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;

protected static final VoxelShape X_AXIS_BOX = Block.createCuboidShape(0.0, 2.0, 2.0, 16.0, 14.0, 14.0);
protected static final VoxelShape Y_AXIS_BOX = Block.createCuboidShape(2.0, 0.0, 2.0, 14.0, 16.0, 14.0);
protected static final VoxelShape Z_AXIS_BOX = Block.createCuboidShape(2.0, 2.0, 0.0, 14.0, 14.0, 16.0);

public BeamBlock(Settings settings) {
super(settings);
setDefaultState(this.stateManager.getDefaultState().with(AXIS, Direction.Axis.Y));
this.setDefaultState(this.getDefaultState().with(WATERLOGGED, false)); // Thanks LambdAurora!
}

// The following deals with block rotation
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
return changeRotation(state, rotation);
}

public static BlockState changeRotation(BlockState state, BlockRotation rotation) {
return switch (rotation) {
case COUNTERCLOCKWISE_90, CLOCKWISE_90 -> switch (state.get(AXIS)) {
case X -> state.with(AXIS, Direction.Axis.Z);
case Z -> state.with(AXIS, Direction.Axis.X);
default -> state;
};
default -> state;
};
}

// Both of the following blocks of code below deals with block collision.
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
Direction.Axis cardinalDir = state.get(AXIS);
return switch (cardinalDir) {
case X -> X_AXIS_BOX;
case Y -> Y_AXIS_BOX;
case Z -> Z_AXIS_BOX;
};
}

// Deals with placing the block properly in accordance to direction.
@Override
public BlockState getPlacementState(ItemPlacementContext context) {
return this.getDefaultState().with(AXIS, context.getSide().getAxis()).with(WATERLOGGED, context.getWorld().getFluidState(context.getBlockPos()).getFluid() == Fluids.WATER);
}

// Deals with block waterlogging. Thanks acikek!
@Override
public FluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
}

@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (state.get(WATERLOGGED)) {
world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}
return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
}

// Appending block properties
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(new Property[]{AXIS, WATERLOGGED});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"variants": {
"axis=x": {
"model": "architecture_extensions:block/birch_beam",
"x": 90,
"y": 90
},
"axis=y": {
"model": "architecture_extensions:block/birch_beam"
},
"axis=z": {
"model": "architecture_extensions:block/birch_beam",
"x": 90
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "architecture_extensions:block/template_beam",
"textures": {
"texture_side": "minecraft:block/stripped_birch_log",
"texture_up": "minecraft:block/stripped_birch_log_top"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"credit": "Made with Blockbench",
"textures": {
"particle": "#texture_side"
},
"elements": [
{
"from": [2, 0, 2],
"to": [14, 16, 14],
"faces": {
"north": {"uv": [2, 0, 14, 16], "texture": "#texture_side"},
"east": {"uv": [2, 0, 14, 16], "texture": "#texture_side"},
"south": {"uv": [2, 0, 14, 16], "texture": "#texture_side"},
"west": {"uv": [2, 0, 14, 16], "texture": "#texture_side"},
"up": {"uv": [2, 2, 14, 14], "texture": "#texture_up", "cullface": "up"},
"down": {"uv": [2, 2, 14, 14], "texture": "#texture_up", "cullface": "down"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"thirdperson_lefthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"firstperson_righthand": {
"rotation": [0, 45, 0],
"scale": [0.4, 0.4, 0.4]
},
"firstperson_lefthand": {
"rotation": [0, 225, 0],
"scale": [0.4, 0.4, 0.4]
},
"ground": {
"translation": [0, 3, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, 225, 0],
"scale": [0.625, 0.625, 0.625]
},
"fixed": {
"scale": [0.5, 0.5, 0.5]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "architecture_extensions:block/birch_beam"
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5378442

Please sign in to comment.