Skip to content

Commit

Permalink
Merge branch 'refs/heads/architectury-1.19.3' into architectury-1.19.4
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
  • Loading branch information
UnlikePaladin committed Oct 7, 2024
2 parents db8fdd2 + 5e05d24 commit 3a1a883
Show file tree
Hide file tree
Showing 23 changed files with 222 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import net.minecraft.state.property.IntProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
Expand All @@ -35,6 +37,7 @@
import java.util.function.Predicate;

import static com.unlikepaladin.pfm.blocks.BasicToiletBlock.checkType;
import static net.minecraft.block.HorizontalFacingBlock.FACING;

public abstract class AbstractSinkBlock extends AbstractCauldronBlock implements BlockEntityProvider {
public static final IntProperty LEVEL_4 = IntProperty.of("level", 0, 3);
Expand Down Expand Up @@ -201,4 +204,14 @@ public void onEntityCollision(BlockState state, World world, BlockPos pos, Entit
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
return false;
}

@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
return state.with(FACING, rotation.rotate(state.get(FACING)));
}

@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
return state.rotate(mirror.getRotation(state.get(FACING)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
Expand All @@ -24,6 +25,8 @@
import java.util.Map;
import java.util.stream.Stream;

import static net.minecraft.block.HorizontalFacingBlock.FACING;

public class BasicCoffeeTableBlock extends Block {
private final Block baseBlock;
public static final EnumProperty<Direction.Axis> AXIS = Properties.HORIZONTAL_AXIS;
Expand Down Expand Up @@ -54,23 +57,7 @@ public static Stream<FurnitureBlock> streamStoneBasicTables() {
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())) {
Expand Down Expand Up @@ -269,6 +256,29 @@ private static VoxelShape getShapeForAxis(Direction.Axis axis, VoxelShape a, Vox
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
return false;
}

@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 BlockState mirror(BlockState state, BlockMirror mirror) {
return state.rotate(mirror.getRotation(Direction.get(Direction.AxisDirection.NEGATIVE, state.get(AXIS))));
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
Expand Down Expand Up @@ -51,23 +52,7 @@ public static Stream<FurnitureBlock> streamStoneBasicTables() {
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())) {
Expand Down Expand Up @@ -266,6 +251,29 @@ private static VoxelShape getShapeForAxis(Direction.Axis axis, VoxelShape a, Vox
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
return false;
}

@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 BlockState mirror(BlockState state, BlockMirror mirror) {
return state.rotate(mirror.getRotation(Direction.get(Direction.AxisDirection.NEGATIVE, state.get(AXIS))));
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ protected HorizontalFacingBlockWithEntity(AbstractBlock.Settings settings) {
}

public BlockState rotate(BlockState state, BlockRotation rotation) {
return (BlockState)state.with(FACING, rotation.rotate((Direction)state.get(FACING)));
return state.with(FACING, rotation.rotate(state.get(FACING)));
}

public BlockState mirror(BlockState state, BlockMirror mirror) {
return state.rotate(mirror.getRotation((Direction)state.get(FACING)));
return state.rotate(mirror.getRotation(state.get(FACING)));
}

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.*;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
Expand Down Expand Up @@ -128,4 +126,14 @@ public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockSt
}
super.onStateReplaced(state, world, pos, newState, moved);
}

@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
return state.with(FACING, rotation.rotate(state.get(FACING)));
}

@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
return state.rotate(mirror.getRotation(state.get(FACING)));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.unlikepaladin.pfm.blocks;

import com.unlikepaladin.pfm.blocks.blockentities.LightSwitchBlockEntity;
import com.unlikepaladin.pfm.blocks.blockentities.StovetopBlockEntity;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
Expand All @@ -18,6 +19,7 @@
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
Expand Down Expand Up @@ -169,6 +171,14 @@ public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockSt
if (state.get(POWERED)) {
this.updateNeighbors(state, world, pos);
}

if (state.isOf(newState.getBlock())) {
return;
}
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof LightSwitchBlockEntity lightSwitchBlockEntity) {
lightSwitchBlockEntity.markRemoved();
}
}

private void updateNeighbors(BlockState state, World world, BlockPos pos) {
Expand All @@ -194,4 +204,5 @@ public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
protected static Direction getDirection(BlockState state) {
return state.get(FACING);
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.unlikepaladin.pfm.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.HorizontalFacingBlock;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public abstract class PowerableBlock extends HorizontalFacingBlock {
public abstract class PowerableBlock extends Block {
protected PowerableBlock(Settings settings) {
super(settings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.state.StateManager;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Hand;
import net.minecraft.util.*;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
Expand Down Expand Up @@ -218,4 +216,14 @@ public DyeColor getPFMColor() {
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new PFMBedBlockEntity(pos, state, this.color);
}

@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
return state.with(FACING, rotation.rotate(state.get(FACING)));
}

@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
return state.rotate(mirror.getRotation(state.get(FACING)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,29 @@
import net.minecraft.util.math.random.Random;

public class ModelHelper {
private static List<Sprite> OAK_SPRITES_PLANKS_TO_REPLACE = null;
public static List<Sprite> OAK_SPRITES_PLANKS_TO_REPLACE = null;
public static List<Sprite> getOakPlankLogSprites() {
if (OAK_SPRITES_PLANKS_TO_REPLACE == null) {
SpriteIdentifier planksId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, WoodVariantRegistry.OAK.getTexture(BlockType.PLANKS));
SpriteIdentifier logId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, WoodVariantRegistry.OAK.getTexture(BlockType.LOG));
SpriteIdentifier planksId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier("minecraft:block/oak_planks"));
SpriteIdentifier logId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier("minecraft:block/oak_log"));
OAK_SPRITES_PLANKS_TO_REPLACE = Arrays.asList(planksId.getSprite(), logId.getSprite());
}
return OAK_SPRITES_PLANKS_TO_REPLACE;
}
private static List<Sprite> OAK_SPRITES_BED_TO_REPLACE = null;
public static List<Sprite> OAK_SPRITES_BED_TO_REPLACE = null;
public static List<Sprite> getOakBedSprites() {
if (OAK_SPRITES_BED_TO_REPLACE == null) {
SpriteIdentifier planksId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, WoodVariantRegistry.OAK.getTexture(BlockType.PLANKS));
SpriteIdentifier planksId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier("minecraft:block/oak_planks"));
SpriteIdentifier bedId = TexturedRenderLayers.BED_TEXTURES[DyeColor.RED.getId()];
OAK_SPRITES_BED_TO_REPLACE = Arrays.asList(planksId.getSprite(), bedId.getSprite());
}
return OAK_SPRITES_BED_TO_REPLACE;
}
private static List<Sprite> OAK_SPRITES_LOG_TOP_TO_REPLACE = null;
public static List<Sprite> OAK_SPRITES_LOG_TOP_TO_REPLACE = null;
public static List<Sprite> getOakLogLogTopSprites() {
if (OAK_SPRITES_LOG_TOP_TO_REPLACE == null) {
SpriteIdentifier logId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, WoodVariantRegistry.OAK.getTexture(BlockType.LOG));
SpriteIdentifier logTopId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, WoodVariantRegistry.OAK.getTexture(BlockType.LOG_TOP));
SpriteIdentifier logId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier("minecraft:block/oak_log"));
SpriteIdentifier logTopId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier("minecraft:block/oak_log_top"));
OAK_SPRITES_LOG_TOP_TO_REPLACE = Arrays.asList(logId.getSprite(), logTopId.getSprite());
}
return OAK_SPRITES_LOG_TOP_TO_REPLACE;
Expand Down Expand Up @@ -160,7 +160,7 @@ public static Block getWoolColor(String string) {
public static Identifier getTextureId(Block block) {
return getTextureId(block, "");
}
private static final Map<Pair<String, String>, Pair<Identifier, Integer>> blockToTextureMap = new HashMap<>();
public static final Map<Pair<String, String>, Pair<Identifier, Integer>> blockToTextureMap = new HashMap<>();
public static Identifier getTextureId(Block block, String postfix) {
if (postfix.isEmpty())
postfix = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

import com.mojang.datafixers.util.Pair;
import com.unlikepaladin.pfm.PaladinFurnitureMod;
import com.unlikepaladin.pfm.blocks.ShowerTowelBlock;
import com.unlikepaladin.pfm.data.materials.WoodVariant;
import com.unlikepaladin.pfm.data.materials.WoodVariantRegistry;
import com.unlikepaladin.pfm.runtime.PFMBakedModelContainer;
import com.unlikepaladin.pfm.runtime.PFMRuntimeResources;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Material;
import net.minecraft.client.render.model.*;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -55,13 +59,21 @@ public class UnbakedBedModel implements UnbakedModel {
public static final List<Identifier> BED_MODEL_IDS = new ArrayList<>() {
{
for(WoodVariant variant : WoodVariantRegistry.getVariants()){
int i = 0;
for (DyeColor dyeColor : DyeColor.values()) {
if (i > 15)
break;
add(new Identifier(PaladinFurnitureMod.MOD_ID, "item/" + variant.asString() + "_" + dyeColor.getName() + "_simple_bed"));
i++;
}
}
for(WoodVariant variant : WoodVariantRegistry.getVariants()){
int i = 0;
for (DyeColor dyeColor : DyeColor.values()) {
if (i > 15)
break;
add(new Identifier(PaladinFurnitureMod.MOD_ID, "item/" + variant.asString() + "_" + dyeColor.getName() + "_classic_bed"));
i++;
}
}
add(BED_MODEL_ID);
Expand Down
Loading

0 comments on commit 3a1a883

Please sign in to comment.