Skip to content

Commit

Permalink
Merge branch 'refs/heads/architectury-1.19.4' into architectury-1.20
Browse files Browse the repository at this point in the history
# Conflicts:
#	common/src/main/java/com/unlikepaladin/pfm/data/materials/StoneVariant.java
#	gradle.properties
  • Loading branch information
UnlikePaladin committed Oct 4, 2024
2 parents b699211 + db8fdd2 commit a7c7172
Show file tree
Hide file tree
Showing 310 changed files with 14,510 additions and 25,733 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v2
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java }}
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
Expand All @@ -33,13 +34,13 @@ jobs:
run: ./gradlew build
- name: capture fabric build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Fabric-Artifacts
path: fabric/build/libs/
- name: capture forge build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Forge-Artifacts
path: forge/build/libs/
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.unlikepaladin.pfm.config.PaladinFurnitureModConfig;

import com.unlikepaladin.pfm.data.materials.DynamicBlockRegistry;
import com.unlikepaladin.pfm.data.materials.StoneVariantRegistry;
import com.unlikepaladin.pfm.data.materials.WoodVariantRegistry;
import com.unlikepaladin.pfm.mixin.PFMPointOfInterestTypesAccessor;
import com.unlikepaladin.pfm.registry.dynamic.FurnitureEntry;
Expand Down Expand Up @@ -60,6 +61,8 @@ public void commonInit() {
updateChecker = new PaladinFurnitureModUpdateChecker();
updateChecker.checkForUpdates(getPFMConfig());
DynamicBlockRegistry.addBlockSetContainer(WoodVariantRegistry.INSTANCE.getType(), WoodVariantRegistry.INSTANCE);
DynamicBlockRegistry.addBlockSetContainer(StoneVariantRegistry.INSTANCE.getType(), StoneVariantRegistry.INSTANCE);

if (getModList().contains("cookingforblockheads"))
pfmModCompatibilities.add(PFMCookingForBlockheads.getInstance());
if (getModList().contains("farmersdelight"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
package com.unlikepaladin.pfm.blocks;

import com.unlikepaladin.pfm.PaladinFurnitureMod;
import com.unlikepaladin.pfm.data.FurnitureBlock;
import net.minecraft.block.*;
import net.minecraft.entity.ai.pathing.NavigationType;
import net.minecraft.fluid.FluidState;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
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.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

public class BasicCoffeeTableBlock extends Block {
private final Block baseBlock;
public static final EnumProperty<Direction.Axis> AXIS = Properties.HORIZONTAL_AXIS;
private final BlockState baseBlockState;
private static final List<FurnitureBlock> WOOD_BASIC_TABLES_COFFEE = new ArrayList<>();
private static final List<FurnitureBlock> STONE_BASIC_TABLES_COFFEE = new ArrayList<>();
public BasicCoffeeTableBlock(Settings settings) {
super(settings);
setDefaultState(this.getStateManager().getDefaultState().with(AXIS, Direction.Axis.X));
this.baseBlockState = this.getDefaultState();
this.baseBlock = baseBlockState.getBlock();
if(AbstractSittableBlock.isWoodBased(baseBlockState) && this.getClass().isAssignableFrom(BasicCoffeeTableBlock.class)){
WOOD_BASIC_TABLES_COFFEE.add(new FurnitureBlock(this, "coffee_table_basic"));
}
else if (this.getClass().isAssignableFrom(BasicCoffeeTableBlock.class)){
STONE_BASIC_TABLES_COFFEE.add(new FurnitureBlock(this, "coffee_table_basic"));
}
}

public static Stream<FurnitureBlock> streamWoodBasicTables() {
return WOOD_BASIC_TABLES_COFFEE.stream();
}
public static Stream<FurnitureBlock> streamStoneBasicTables() {
return STONE_BASIC_TABLES_COFFEE.stream();
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(AXIS);
}
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
switch (rotation) {
case COUNTERCLOCKWISE_90, CLOCKWISE_90 -> {
switch (state.get(AXIS)) {
case X -> {
return state.with(AXIS, Direction.Axis.Z);
}
case Z -> {
return state.with(AXIS, Direction.Axis.X);
}
}
return state;
}
}
return state;
}
@Override
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) {
if (!state.isOf(state.getBlock())) {
this.baseBlockState.neighborUpdate(world, pos, Blocks.AIR, pos, false);
this.baseBlock.onBlockAdded(this.baseBlockState, world, pos, oldState, false);
}
}
@Override
public boolean isShapeFullCube(BlockState state, BlockView world, BlockPos pos) {
return false;
}

@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
}

public BlockState getPlacementState(ItemPlacementContext ctx) {
Direction.Axis facing = ctx.getHorizontalPlayerFacing().getAxis();
return this.getDefaultState().with(AXIS, facing);
}
@Override
public FluidState getFluidState(BlockState state) {
return super.getFluidState(state);
}

public boolean canConnect(BlockState blockState)
{
return PaladinFurnitureMod.getPFMConfig().doTablesOfDifferentMaterialsConnect() ? blockState.getBlock() instanceof BasicCoffeeTableBlock : blockState.getBlock() == this;
}

public int getFlammability(BlockState state, BlockView world, BlockPos pos, Direction face) {
if (AbstractSittableBlock.isWoodBased(state)) {
return 20;
}
return 0;
}

/** Method to rotate VoxelShapes from this random Forge Forums thread: https://forums.minecraftforge.net/topic/74979-1144-rotate-voxel-shapes/ */
public static VoxelShape rotateShape(Direction from, Direction to, VoxelShape shape) {
VoxelShape[] buffer = new VoxelShape[]{ shape, VoxelShapes.empty() };
int times = (to.getHorizontal() - from.getHorizontal() + 4) % 4;
for (int i = 0; i < times; i++) {
buffer[0].forEachBox((minX, minY, minZ, maxX, maxY, maxZ) -> buffer[1] = VoxelShapes.union(buffer[1], VoxelShapes.cuboid(1-maxZ, minY, minX, 1-minZ, maxY, maxX)));
buffer[0] = buffer[1];
buffer[1] = VoxelShapes.empty();
}
return buffer[0];
}

final static VoxelShape TABLE_BASIC_BASE = createCuboidShape(0, 8, 0, 16, 10, 16);
final static VoxelShape TABLE_BASIC_NORTH_EAST_LEG = createCuboidShape(12, 0, 2, 14, 8, 4);
final static VoxelShape TABLE_BASIC_SOUTH_WEST_LEG = createCuboidShape(2, 0, 12,4, 8, 14);
final static VoxelShape TABLE_BASIC_NORTH_WEST_LEG = createCuboidShape(2, 0, 2,4, 8, 4);
final static VoxelShape TABLE_BASIC_SOUTH_EAST_LEG = createCuboidShape(12, 0, 12,14, 8, 14);
final static VoxelShape TABLE_BASIC_EAST_WEST_NORTH = createCuboidShape(4, 0, 2,12, 2, 4);
final static VoxelShape TABLE_BASIC_EAST_WEST_SOUTH = createCuboidShape(4, 0, 12,12, 2, 14);
final static VoxelShape TABLE_BASIC_SOUTH_EAST_TOP = createCuboidShape(4, 0, 2,16, 2, 4);
final static VoxelShape TABLE_BASIC_SOUTH_EAST_BOTTOM = createCuboidShape(4, 0, 12,16, 2, 14);
final static VoxelShape TABLE_BASIC_SOUTH_WEST_BOTTOM = createCuboidShape(0, 0, 12,12, 2, 14);
final static VoxelShape TABLE_BASIC_SOUTH_WEST_TOP = createCuboidShape(0, 0, 2,12, 2, 4);
final static VoxelShape TABLE_BASIC_NORTH_SOUTH_WEST = createCuboidShape(0, 0, 2,16, 2, 4);
final static VoxelShape TABLE_BASIC_NORTH_SOUTH_EAST = createCuboidShape(0, 0, 12, 16, 2, 14);
final static VoxelShape TABLE_BASIC_NORTH_EAST_CORNER = createCuboidShape(14, 0, 2, 16, 2, 4);
final static VoxelShape TABLE_BASIC_SOUTH_EAST_CORNER = createCuboidShape(14, 0, 12, 16, 2, 14);
final static VoxelShape TABLE_BASIC_NORTH_WEST_CORNER = createCuboidShape(0, 0, 2, 2, 2, 4);
final static VoxelShape TABLE_BASIC_SOUTH_WEST_CORNER = createCuboidShape(0, 0, 12, 2, 2, 14);
final static Map<String, VoxelShape> VOXEL_SHAPES = new HashMap<>();

public boolean canConnect(BlockView world, BlockState state, BlockPos neighborPos, BlockPos pos){
BlockState neighborState = world.getBlockState(neighborPos);
if (neighborState.contains(AXIS)) {
return neighborState.get(AXIS) == state.get(AXIS) && canConnect(neighborState);
}
return false;
}

public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
Direction.Axis dir = state.get(BasicCoffeeTableBlock.AXIS);

Boolean north = canConnect(world, state, pos.north(), pos);
boolean east = canConnect(world, state, pos.east(), pos);
boolean west = canConnect(world, state, pos.west(), pos);
boolean south = canConnect(world, state, pos.south(), pos);
boolean cornerNorthWest = north && west && !canConnect(world, state, pos.north().west(), pos);
boolean cornerNorthEast = north && east && !canConnect(world, state, pos.north().east(), pos);
boolean cornerSouthEast = south && east && !canConnect(world, state, pos.south().east(), pos);
boolean cornerSouthWest = south && west && !canConnect(world, state, pos.south().west(), pos);

String key = north.toString()+ east + west + south + cornerNorthWest + cornerNorthEast + cornerSouthEast + cornerSouthWest + dir.asString();
if (!VOXEL_SHAPES.containsKey(key)) {
generateVoxelShape(key, north, east, west, south, cornerNorthWest, cornerNorthEast, cornerSouthEast, cornerSouthWest, dir);
}
return VOXEL_SHAPES.get(key);
}

private static void generateVoxelShape(String key, Boolean north, Boolean east, Boolean west, Boolean south, Boolean cornerNorthWest, Boolean cornerNorthEast, Boolean cornerSouthEast, Boolean cornerSouthWest, Direction.Axis axis) {
VoxelShape newVoxelShape = TABLE_BASIC_BASE;
if (!north && !south && !east && !west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_EAST_WEST_NORTH, TABLE_BASIC_EAST_WEST_SOUTH);
}
if (!north && !east) {
newVoxelShape = VoxelShapes.union(newVoxelShape, getShapeForAxis(axis, TABLE_BASIC_NORTH_EAST_LEG, TABLE_BASIC_NORTH_WEST_LEG));
}
if (!north && !west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, getShapeForAxis(axis, TABLE_BASIC_NORTH_WEST_LEG, TABLE_BASIC_SOUTH_WEST_LEG));
}
if (!south && !east) {
newVoxelShape = VoxelShapes.union(newVoxelShape, getShapeForAxis(axis, TABLE_BASIC_SOUTH_EAST_LEG, TABLE_BASIC_NORTH_EAST_LEG));
}
if (!south && !west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, getShapeForAxis(axis, TABLE_BASIC_SOUTH_WEST_LEG, TABLE_BASIC_SOUTH_EAST_LEG));
}
if (cornerNorthEast) {
newVoxelShape = VoxelShapes.union(newVoxelShape, getShapeForAxis(axis, VoxelShapes.union(TABLE_BASIC_NORTH_EAST_LEG, TABLE_BASIC_NORTH_EAST_CORNER), VoxelShapes.union(TABLE_BASIC_NORTH_WEST_LEG, TABLE_BASIC_NORTH_WEST_CORNER)));
}
if (cornerNorthWest) {
newVoxelShape = VoxelShapes.union(newVoxelShape, getShapeForAxis(axis, VoxelShapes.union(TABLE_BASIC_NORTH_WEST_LEG, TABLE_BASIC_NORTH_WEST_CORNER), VoxelShapes.union(TABLE_BASIC_SOUTH_WEST_LEG, TABLE_BASIC_SOUTH_WEST_CORNER)));
}
if (cornerSouthWest) {
newVoxelShape = VoxelShapes.union(newVoxelShape, getShapeForAxis(axis, VoxelShapes.union(TABLE_BASIC_SOUTH_WEST_LEG, TABLE_BASIC_SOUTH_WEST_CORNER), VoxelShapes.union(TABLE_BASIC_SOUTH_EAST_LEG, TABLE_BASIC_SOUTH_EAST_CORNER)));
}
if (cornerSouthEast) {
newVoxelShape = VoxelShapes.union(newVoxelShape, getShapeForAxis(axis, VoxelShapes.union(TABLE_BASIC_SOUTH_EAST_LEG, TABLE_BASIC_SOUTH_EAST_CORNER), VoxelShapes.union(TABLE_BASIC_NORTH_EAST_LEG, TABLE_BASIC_NORTH_EAST_CORNER)));
}

if (axis == Direction.Axis.Z) {
if (!north && south && !east && !west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_EAST_WEST_NORTH);
}
if (north && !south && !east && !west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_EAST_WEST_SOUTH);
}
if (!north && east && !west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_SOUTH_EAST_TOP);
}
if (!south && !east && west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_SOUTH_WEST_BOTTOM);
}
if (!south && east && !west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_SOUTH_EAST_BOTTOM);
}
if (!north && !east && west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_SOUTH_WEST_TOP);
}
if (!north && east && west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_NORTH_SOUTH_WEST);
}
if (!south && east && west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_NORTH_SOUTH_EAST);
}
}
else {
if (!north && south && !west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_SOUTH_EAST_BOTTOM);
}
if (north && !south && !west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_SOUTH_WEST_BOTTOM);
}
if (!north && south && !east) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_SOUTH_EAST_TOP);
}
if (north && !south && !east) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_SOUTH_WEST_TOP);
}
if (north && !south && !east) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_SOUTH_WEST_TOP);
}
if (!north && !south && !east) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_EAST_WEST_NORTH);
}
if (!north && !south && !west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_EAST_WEST_SOUTH);
}
if (north && south && !east) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_NORTH_SOUTH_WEST);
}
if (north && south && !west) {
newVoxelShape = VoxelShapes.union(newVoxelShape, TABLE_BASIC_NORTH_SOUTH_EAST);
}
newVoxelShape = rotateShape(Direction.NORTH, Direction.EAST, newVoxelShape);
}
VOXEL_SHAPES.put(key, newVoxelShape);
}

private static VoxelShape getShapeForAxis(Direction.Axis axis, VoxelShape a, VoxelShape b) {
if (axis == Direction.Axis.Z) {
return a;
} else if (axis == Direction.Axis.X) {
return b;
}
return VoxelShapes.empty();
}

@Override
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
return false;
}
}


Loading

0 comments on commit a7c7172

Please sign in to comment.