diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/AbstractSinkBlock.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/AbstractSinkBlock.java index 44df247a2..4c3e2fddc 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/AbstractSinkBlock.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/AbstractSinkBlock.java @@ -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; @@ -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); @@ -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))); + } } diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/BasicCoffeeTableBlock.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/BasicCoffeeTableBlock.java index 28e26ca0e..d4d902ea1 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/BasicCoffeeTableBlock.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/BasicCoffeeTableBlock.java @@ -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; @@ -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 AXIS = Properties.HORIZONTAL_AXIS; @@ -54,23 +57,7 @@ public static Stream streamStoneBasicTables() { protected void appendProperties(StateManager.Builder 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())) { @@ -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)))); + } } diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/BasicTableBlock.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/BasicTableBlock.java index 141e3c6c1..5162d12bc 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/BasicTableBlock.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/BasicTableBlock.java @@ -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; @@ -51,23 +52,7 @@ public static Stream streamStoneBasicTables() { protected void appendProperties(StateManager.Builder 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())) { @@ -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)))); + } } diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/HorizontalFacingBlockWithEntity.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/HorizontalFacingBlockWithEntity.java index 32f093788..39f57b6f9 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/HorizontalFacingBlockWithEntity.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/HorizontalFacingBlockWithEntity.java @@ -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 { diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/InnerTrashcanBlock.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/InnerTrashcanBlock.java index 9cc665203..c8ec5d7d9 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/InnerTrashcanBlock.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/InnerTrashcanBlock.java @@ -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; @@ -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))); + } } diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/LightSwitchBlock.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/LightSwitchBlock.java index 7ff6a7fa2..86faee8d7 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/LightSwitchBlock.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/LightSwitchBlock.java @@ -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; @@ -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; @@ -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) { @@ -194,4 +204,5 @@ public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { protected static Direction getDirection(BlockState state) { return state.get(FACING); } + } diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/PowerableBlock.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/PowerableBlock.java index 8b72c682a..05e782816 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/PowerableBlock.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/PowerableBlock.java @@ -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); } diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/SimpleBedBlock.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/SimpleBedBlock.java index a0c4698ba..ab43a2f1b 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/SimpleBedBlock.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/SimpleBedBlock.java @@ -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; @@ -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))); + } } diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java index cf405ff23..eb1bcee9a 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java @@ -34,29 +34,29 @@ import net.minecraft.util.math.random.Random; public class ModelHelper { - private static List OAK_SPRITES_PLANKS_TO_REPLACE = null; + public static List OAK_SPRITES_PLANKS_TO_REPLACE = null; public static List 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 OAK_SPRITES_BED_TO_REPLACE = null; + public static List OAK_SPRITES_BED_TO_REPLACE = null; public static List 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 OAK_SPRITES_LOG_TOP_TO_REPLACE = null; + public static List OAK_SPRITES_LOG_TOP_TO_REPLACE = null; public static List 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; @@ -160,7 +160,7 @@ public static Block getWoolColor(String string) { public static Identifier getTextureId(Block block) { return getTextureId(block, ""); } - private static final Map, Pair> blockToTextureMap = new HashMap<>(); + public static final Map, Pair> blockToTextureMap = new HashMap<>(); public static Identifier getTextureId(Block block, String postfix) { if (postfix.isEmpty()) postfix = null; diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/bed/UnbakedBedModel.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/bed/UnbakedBedModel.java index 368edc9df..bc028f5cc 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/bed/UnbakedBedModel.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/bed/UnbakedBedModel.java @@ -2,6 +2,7 @@ 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; @@ -9,9 +10,11 @@ import dev.architectury.injectables.annotations.ExpectPlatform; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.block.AbstractBlock; 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; @@ -55,13 +58,21 @@ public class UnbakedBedModel implements UnbakedModel { public static final List 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); diff --git a/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMReloadableResourceManagerImplMixin.java b/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMReloadableResourceManagerImplMixin.java index adf198713..8f20d0e11 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMReloadableResourceManagerImplMixin.java +++ b/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMReloadableResourceManagerImplMixin.java @@ -1,22 +1,32 @@ package com.unlikepaladin.pfm.mixin; -import com.unlikepaladin.pfm.client.PathPackRPWrapper; +import com.unlikepaladin.pfm.blocks.models.ModelHelper; import com.unlikepaladin.pfm.runtime.PFMRuntimeResources; import net.minecraft.resource.ReloadableResourceManagerImpl; import net.minecraft.resource.ResourcePack; +import net.minecraft.resource.ResourceReload; +import net.minecraft.util.Unit; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; @Mixin(value = ReloadableResourceManagerImpl.class) public class PFMReloadableResourceManagerImplMixin { - @ModifyVariable(at = @At(value = "HEAD"), method = "reload", argsOnly = true) - private List createReload(List packs) { + @Inject(at = @At(value = "HEAD"), method = "reload") + private void createReload(Executor prepareExecutor, Executor applyExecutor, CompletableFuture initialStage, List packs, CallbackInfoReturnable cir) { PFMRuntimeResources.modelCacheMap.clear(); - return packs; + ModelHelper.blockToTextureMap.clear(); + if (ModelHelper.OAK_SPRITES_PLANKS_TO_REPLACE != null) + ModelHelper.OAK_SPRITES_PLANKS_TO_REPLACE = null; + if (ModelHelper.OAK_SPRITES_BED_TO_REPLACE != null) + ModelHelper.OAK_SPRITES_BED_TO_REPLACE = null; + if (ModelHelper.OAK_SPRITES_LOG_TOP_TO_REPLACE != null) + ModelHelper.OAK_SPRITES_LOG_TOP_TO_REPLACE = null; } } \ No newline at end of file diff --git a/common/src/main/java/com/unlikepaladin/pfm/registry/dynamic/LateBlockRegistry.java b/common/src/main/java/com/unlikepaladin/pfm/registry/dynamic/LateBlockRegistry.java index 5fd9af4d4..e6d171c1e 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/registry/dynamic/LateBlockRegistry.java +++ b/common/src/main/java/com/unlikepaladin/pfm/registry/dynamic/LateBlockRegistry.java @@ -80,8 +80,12 @@ public static void registerBlocks() throws InvocationTargetException, Instantiat this.addBlock(variant, LateBlockRegistry.registerLateBlock( variant.asString()+"_chair_classic", () -> new ClassicChairBlock(AbstractBlock.Settings.copy(variant.getBaseBlock()).nonOpaque()), true, PaladinFurnitureMod.FURNITURE_GROUP), true); }}}); PaladinFurnitureMod.furnitureEntryMap.put(ClassicChairDyeableBlock.class, new FurnitureEntry<>() {{ + int i = 0; for (DyeColor color : DyeColor.values()) { + if (i > 15) + break; this.addBlock(registerLateBlock("oak_chair_classic_" + color.getName(), () -> new ClassicChairDyeableBlock(color, AbstractBlock.Settings.copy(PaladinFurnitureMod.furnitureEntryMap.get(BasicChairBlock.class).allBlocks.get(0))), true, PaladinFurnitureMod.FURNITURE_GROUP)); + i++; } }}); @@ -103,15 +107,24 @@ public static void registerBlocks() throws InvocationTargetException, Instantiat this.addBlock(registerLateBlock("froggy_chair_yellow", () -> new FroggyChairBlock(AbstractBlock.Settings.copy(this.allBlocks.get(0)).mapColor(MapColor.YELLOW)), true, PaladinFurnitureMod.FURNITURE_GROUP)); }}); PaladinFurnitureMod.furnitureEntryMap.put(SimpleSofaBlock.class, new FurnitureEntry<>() {{ + int i = 0; for (DyeColor color : DyeColor.values()) { + if (i > 15) + break; this.addBlock(registerLateBlock(color.getName() + "_simple_sofa", () -> new SimpleSofaBlock(color, AbstractBlock.Settings.create().burnable().strength(2.0f).resistance(2.0f).nonOpaque().sounds(BlockSoundGroup.WOOL).mapColor(color.getMapColor())), true, PaladinFurnitureMod.FURNITURE_GROUP)); - }}}); + i++; + } + }}); PaladinFurnitureMod.furnitureEntryMap.put(ArmChairBlock.class, new FurnitureEntry<>() {{ this.addBlock(registerLateBlock("arm_chair_leather", () -> new ArmChairBlock(AbstractBlock.Settings.create().strength(2.0f).resistance(2.0f).nonOpaque().sounds(BlockSoundGroup.WOOL)), true, PaladinFurnitureMod.FURNITURE_GROUP)); }}); PaladinFurnitureMod.furnitureEntryMap.put(ArmChairColoredBlock.class, new FurnitureEntry<>() {{ + int i = 0; for (DyeColor color : DyeColor.values()) { + if (i > 15) + break; this.addBlock(registerLateBlock(color.getName() + "_arm_chair", () -> new ArmChairColoredBlock(color, AbstractBlock.Settings.create().burnable().strength(2.0f).resistance(2.0f).nonOpaque().sounds(BlockSoundGroup.WOOL).mapColor(color.getMapColor())), true, PaladinFurnitureMod.FURNITURE_GROUP)); + i++; } }}); @@ -209,19 +222,27 @@ public static void registerBlocks() throws InvocationTargetException, Instantiat }}}); PaladinFurnitureMod.furnitureEntryMap.put(SimpleBedBlock.class, new FurnitureEntry<>() {{ for (WoodVariant variant : WoodVariantRegistry.getVariants()) { - for (DyeColor color : DyeColor.values()) { - SimpleBedBlock block = LateBlockRegistry.registerLateBlock(variant.asString() + "_" + color.getName() + "_simple_bed", () -> new SimpleBedBlock(color, AbstractBlock.Settings.create().mapColor(state -> state.get(BedBlock.PART) == BedPart.FOOT ? color.getMapColor() : MapColor.WHITE_GRAY).sounds(variant.getBaseBlock().getSoundGroup(variant.getBaseBlock().getDefaultState())).requires(variant.getFeatureList().toArray(new FeatureFlag[0])).strength(0.2f).nonOpaque()), 1, PaladinFurnitureMod.FURNITURE_GROUP); - this.addBlock(variant, block, true); + int i = 0;for (DyeColor color : DyeColor.values()) { + if (i > 15) + break; + SimpleBedBlock block = LateBlockRegistry.registerLateBlock(variant.asString() + "_" + color.getName() + "_simple_bed", () -> new SimpleBedBlock(color, AbstractBlock.Settings.create().mapColor(state -> state.get(BedBlock.PART) == BedPart.FOOT ? color.getMapColor() : MapColor.WHITE_GRAY).sounds(variant.getBaseBlock().getSoundGroup(variant.getBaseBlock().getDefaultState())).requires(variant.getFeatureList().toArray(new FeatureFlag[0])).strength(0.2f).nonOpaque()), 1, PaladinFurnitureMod.FURNITURE_GROUP); this.addBlock(variant, block, true); PaladinFurnitureModBlocksItems.beds.add(block); - }}}}); + i++; + } + } + }}); PaladinFurnitureMod.furnitureEntryMap.put(ClassicBedBlock.class, new FurnitureEntry<>() {{ for (WoodVariant variant : WoodVariantRegistry.getVariants()) { - for (DyeColor color : DyeColor.values()) { + int i = 0;for (DyeColor color : DyeColor.values()) { + if (i > 15) + break; ClassicBedBlock block = LateBlockRegistry.registerLateBlock(variant.asString() + "_" + color.getName() + "_classic_bed", () -> new ClassicBedBlock(color, AbstractBlock.Settings.create().mapColor(state -> state.get(BedBlock.PART) == BedPart.FOOT ? color.getMapColor() : MapColor.WHITE_GRAY).sounds(variant.getBaseBlock().getSoundGroup(variant.getBaseBlock().getDefaultState())).strength(0.2f).nonOpaque().requires(variant.getFeatureList().toArray(new FeatureFlag[0]))), 1, PaladinFurnitureMod.FURNITURE_GROUP); this.addBlock(variant, block, true); PaladinFurnitureModBlocksItems.beds.add(block); + i++; } - }}}); + } + }}); PaladinFurnitureMod.furnitureEntryMap.put(SimpleBunkLadderBlock.class, new FurnitureEntry<>() {{ for (WoodVariant variant : WoodVariantRegistry.getVariants()) { this.addBlock(variant, LateBlockRegistry.registerLateBlock(variant.asString()+"_simple_bunk_ladder", () -> new SimpleBunkLadderBlock(AbstractBlock.Settings.copy(variant.getBaseBlock()).nonOpaque()), true, PaladinFurnitureMod.FURNITURE_GROUP), true); @@ -392,8 +413,12 @@ public static void registerBlocks() throws InvocationTargetException, Instantiat this.addBlock( LateBlockRegistry.registerLateBlock( "mesh_trashcan",() -> PaladinFurnitureModBlocksItems.MESH_TRASHCAN, true, PaladinFurnitureMod.FURNITURE_GROUP)); }}); PaladinFurnitureMod.furnitureEntryMap.put(ShowerTowelBlock.class, new FurnitureEntry() {{ + int i = 0; for (DyeColor color : DyeColor.values()) { + if (i > 15) + break; this.addBlock(registerLateBlock(color.getName() + "_shower_towel", () -> new ShowerTowelBlock(color, AbstractBlock.Settings.create().burnable().strength(2.0f).resistance(2.0f).nonOpaque().sounds(BlockSoundGroup.WOOL).mapColor(color.getMapColor())), true, PaladinFurnitureMod.FURNITURE_GROUP)); + i++; } }}); if (!BlockItemRegistry.isModLoaded("imm_ptl_core")) { diff --git a/common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java b/common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java index 46b3fea01..172dc8ea9 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java +++ b/common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java @@ -226,7 +226,10 @@ public String translate(String key, Object ... args) { public void generateTranslationForLampBlock(BufferedWriter writer) { for (WoodVariant variant : WoodVariantRegistry.getVariants()) { + int i = 0; for (DyeColor color : DyeColor.values()) { + if (i > 15) + break; try { String translatedVariantName = getTranslatedVariantName(variant); String translatedColor = translate("color.minecraft."+color.getName()); @@ -237,6 +240,7 @@ public void generateTranslationForLampBlock(BufferedWriter writer) { getParent().getLogger().error("Writer exception: " + e); throw new RuntimeException(e); } + i++; } } } diff --git a/common/src/main/java/com/unlikepaladin/pfm/runtime/data/PFMRecipeProvider.java b/common/src/main/java/com/unlikepaladin/pfm/runtime/data/PFMRecipeProvider.java index fd69d793a..bc94db5d8 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/runtime/data/PFMRecipeProvider.java +++ b/common/src/main/java/com/unlikepaladin/pfm/runtime/data/PFMRecipeProvider.java @@ -419,7 +419,7 @@ protected void generateRecipes(Consumer exporter) { PaladinFurnitureMod.furnitureEntryMap.get(KitchenWallCounterBlock.class).getVariantToBlockMap().forEach((variantBase, block) -> { if (!generatedRecipes.contains(getId(block))) { Pair materials = getCounterMaterials(variantBase); - offerCounterRecipe(block.asItem(), Ingredient.ofItems(materials.getRight()), Ingredient.ofItems(materials.getRight()), exporter); + offerCounterRecipe(block.asItem(), Ingredient.ofItems(materials.getLeft()), Ingredient.ofItems(materials.getLeft()), exporter); generatedRecipes.add(getId(block)); } }); @@ -432,20 +432,20 @@ protected void generateRecipes(Consumer exporter) { PaladinFurnitureMod.furnitureEntryMap.get(KitchenWallDrawerBlock.class).getVariantToBlockMap().forEach((variantBase, block) -> { if (!generatedRecipes.contains(getId(block))) { Pair materials = getCounterMaterials(variantBase); - offerWallDrawerRecipe(block.asItem(), Ingredient.ofItems(materials.getRight()), Ingredient.ofItems(materials.getRight()), Ingredient.ofItems(Items.CHEST), exporter); + offerWallDrawerRecipe(block.asItem(), Ingredient.ofItems(materials.getRight()), Ingredient.ofItems(materials.getLeft()), Ingredient.ofItems(Items.CHEST), exporter); generatedRecipes.add(getId(block)); } }); PaladinFurnitureMod.furnitureEntryMap.get(KitchenWallDrawerBlock.class).getVariantToBlockMapNonBase().forEach((variantBase, block) -> { if (!generatedRecipes.contains(getId(block))) { - offerWallDrawerRecipe(block.asItem(), Ingredient.ofItems((Block)variantBase.getChild("stripped_log")), Ingredient.ofItems((Block)variantBase.getChild("stripped_log")), Ingredient.ofItems(Items.CHEST), exporter); + offerWallDrawerRecipe(block.asItem(), Ingredient.ofItems((Block)variantBase.getChild("stripped_log")), Ingredient.ofItems(variantBase.getBaseBlock()), Ingredient.ofItems(Items.CHEST), exporter); generatedRecipes.add(getId(block)); } }); PaladinFurnitureMod.furnitureEntryMap.get(KitchenWallDrawerSmallBlock.class).getVariantToBlockMap().forEach((variantBase, block) -> { if (!generatedRecipes.contains(getId(block))) { Pair materials = getCounterMaterials(variantBase); - offerWallDrawerSmallRecipe(block.asItem(), Ingredient.ofItems(materials.getRight()), Ingredient.ofItems(materials.getRight()), Ingredient.ofItems(Items.CHEST), exporter); + offerWallDrawerSmallRecipe(block.asItem(), Ingredient.ofItems(materials.getRight()), Ingredient.ofItems(materials.getLeft()), Ingredient.ofItems(Items.CHEST), exporter); generatedRecipes.add(getId(block)); } }); @@ -931,7 +931,12 @@ private static InventoryChangedCriterion.Conditions conditionsFromItemPredicates } private static String getItemPath(Ingredient item) { - return Registries.ITEM.getId(item.getMatchingStacks()[0].getItem()).getPath(); + ItemStack[] n = item.getMatchingStacks(); + if (n.length > 0) { + return Registries.ITEM.getId(n[0].getItem()).getPath(); + } else { + return item.toString(); + } } private static String getItemPath(ItemConvertible item) { return Registries.ITEM.getId(item.asItem()).getPath(); diff --git a/common/src/main/resources/assets/pfm/blockstates/kitchen_stovetop.json b/common/src/main/resources/assets/pfm/blockstates/kitchen_stovetop.json index 28572781f..e2d3d2256 100755 --- a/common/src/main/resources/assets/pfm/blockstates/kitchen_stovetop.json +++ b/common/src/main/resources/assets/pfm/blockstates/kitchen_stovetop.json @@ -1,9 +1,9 @@ {"variants": { - "facing=north":{"model":"pfm:block/kitchen_counter/kitchen_stovetop","y":180,"uvlock":"true"}, - "facing=east":{"model":"pfm:block/kitchen_counter/kitchen_stovetop","y":270,"uvlock":"true"}, - "facing=south":{"model":"pfm:block/kitchen_counter/kitchen_stovetop","y":0,"uvlock":"true"}, - "facing=west":{"model":"pfm:block/kitchen_counter/kitchen_stovetop","y":90,"uvlock":"true"} + "facing=north":{"model":"pfm:block/kitchen_counter/kitchen_stovetop","y":180,"uvlock":"false"}, + "facing=east":{"model":"pfm:block/kitchen_counter/kitchen_stovetop","y":270,"uvlock":"false"}, + "facing=south":{"model":"pfm:block/kitchen_counter/kitchen_stovetop","y":0,"uvlock":"false"}, + "facing=west":{"model":"pfm:block/kitchen_counter/kitchen_stovetop","y":90,"uvlock":"false"} } diff --git a/common/src/main/resources/assets/pfm/models/block/kitchen_counter/kitchen_stovetop.json b/common/src/main/resources/assets/pfm/models/block/kitchen_counter/kitchen_stovetop.json index 79a898fac..8627e2e3d 100755 --- a/common/src/main/resources/assets/pfm/models/block/kitchen_counter/kitchen_stovetop.json +++ b/common/src/main/resources/assets/pfm/models/block/kitchen_counter/kitchen_stovetop.json @@ -2,6 +2,7 @@ "credit": "By UnlikePaladin", "texture_size": [64, 64], "textures": { + "particle": "pfm:block/iron_stove", "6": "pfm:block/iron_stove" }, "elements": [ @@ -21,7 +22,7 @@ "rotation": {"angle": 0, "axis": "y", "origin": [8, 0.75, 9]}, "faces": { "up": {"uv": [12.5, 0.25, 16, 3], "rotation": 180, "texture": "#6"}, - "down": {"uv": [6.5, 2, 8.5, 12.2], "rotation": 180, "texture": "#missing"} + "down": {"uv": [6.5, 2, 8.5, 12.2], "rotation": 180, "texture": "#6"} } }, { diff --git a/fabric/build.gradle b/fabric/build.gradle index 7f6ceed5b..0646906e9 100755 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -258,3 +258,9 @@ publishing { // Add repositories to publish to here. } } + +configurations.configureEach { + resolutionStrategy { + force("net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}") + } +} \ No newline at end of file diff --git a/fabric/src/main/java/com/unlikepaladin/pfm/blocks/models/basicLamp/fabric/FabricBasicLampModel.java b/fabric/src/main/java/com/unlikepaladin/pfm/blocks/models/basicLamp/fabric/FabricBasicLampModel.java index bf6b134b0..54f294a22 100644 --- a/fabric/src/main/java/com/unlikepaladin/pfm/blocks/models/basicLamp/fabric/FabricBasicLampModel.java +++ b/fabric/src/main/java/com/unlikepaladin/pfm/blocks/models/basicLamp/fabric/FabricBasicLampModel.java @@ -89,13 +89,13 @@ public ModelTransformation getTransformation() { static List getOakStrippedLogSprite() { if (!oakSprite.isEmpty()) return oakSprite; - Sprite wood = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, WoodVariantRegistry.OAK.getTexture(BlockType.STRIPPED_LOG)).getSprite(); + Sprite wood = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier("minecraft:block/stripped_oak_log")).getSprite(); oakSprite.add(wood); return oakSprite; } - static Map> sprites = new HashMap<>(); - static List getVariantStrippedLogSprite(WoodVariant variant) { + Map> sprites = new HashMap<>(); + List getVariantStrippedLogSprite(WoodVariant variant) { if (sprites.containsKey(variant)) return sprites.get(variant); diff --git a/forge/build.gradle b/forge/build.gradle index 898f591d9..62eb8ae9a 100755 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -111,6 +111,10 @@ if (rootProject.rei_compatibility == "true"){ transitive(false) } } +} else { + dependencies { + modCompileOnly("me.shedaniel:RoughlyEnoughItems-forge:${rootProject.rei_version}") + } } diff --git a/forge/src/main/java/com/unlikepaladin/pfm/blocks/models/basicLamp/forge/ForgeBasicLampModel.java b/forge/src/main/java/com/unlikepaladin/pfm/blocks/models/basicLamp/forge/ForgeBasicLampModel.java index b2a0e0d1f..b35d821b2 100644 --- a/forge/src/main/java/com/unlikepaladin/pfm/blocks/models/basicLamp/forge/ForgeBasicLampModel.java +++ b/forge/src/main/java/com/unlikepaladin/pfm/blocks/models/basicLamp/forge/ForgeBasicLampModel.java @@ -67,13 +67,13 @@ public ModelData getModelData(@NotNull BlockRenderView world, @NotNull BlockPos static List getOakStrippedLogSprite() { if (!oakSprite.isEmpty()) return oakSprite; - Sprite wood = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, WoodVariantRegistry.OAK.getTexture(BlockType.STRIPPED_LOG)).getSprite(); + Sprite wood = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier("minecraft:block/stripped_oak_log")).getSprite(); oakSprite.add(wood); return oakSprite; } - static Map> sprites = new HashMap<>(); - static List getVariantStrippedLogSprite(WoodVariant variant) { + Map> sprites = new HashMap<>(); + List getVariantStrippedLogSprite(WoodVariant variant) { if (sprites.containsKey(variant)) return sprites.get(variant); diff --git a/forge/src/main/java/com/unlikepaladin/pfm/blocks/models/forge/PFMForgeBakedModel.java b/forge/src/main/java/com/unlikepaladin/pfm/blocks/models/forge/PFMForgeBakedModel.java index c7801e20c..1f1780298 100644 --- a/forge/src/main/java/com/unlikepaladin/pfm/blocks/models/forge/PFMForgeBakedModel.java +++ b/forge/src/main/java/com/unlikepaladin/pfm/blocks/models/forge/PFMForgeBakedModel.java @@ -35,6 +35,18 @@ public List getQuads(ItemStack stack, @Nullable BlockState state, @Nu return getQuads(state, face, random); } + Map, List> cache = new HashMap<>(); + @Override + public List getQuadsCached(ItemStack stack, @Nullable BlockState state, @Nullable Direction face, Random random) { + Pair directionPair = new Pair<>(stack, face); + if (cache.containsKey(directionPair)) + return cache.get(directionPair); + + List quads = getQuads(stack, state, face, random); + cache.put(directionPair, quads); + return quads; + } + public PFMForgeBakedModel(ModelBakeSettings settings, List templateBakedModels) { super(settings, templateBakedModels); } diff --git a/forge/src/main/java/com/unlikepaladin/pfm/client/forge/PFMBakedModelGetQuadsExtension.java b/forge/src/main/java/com/unlikepaladin/pfm/client/forge/PFMBakedModelGetQuadsExtension.java index e8fbfb552..26318eb50 100644 --- a/forge/src/main/java/com/unlikepaladin/pfm/client/forge/PFMBakedModelGetQuadsExtension.java +++ b/forge/src/main/java/com/unlikepaladin/pfm/client/forge/PFMBakedModelGetQuadsExtension.java @@ -16,14 +16,5 @@ public interface PFMBakedModelGetQuadsExtension { List getQuads(ItemStack stack, @Nullable BlockState state, @Nullable Direction face, Random random); - Map, List> cache = new HashMap<>(); - default List getQuadsCached(ItemStack stack, @Nullable BlockState state, @Nullable Direction face, Random random) { - Pair directionPair = new Pair<>(stack, face); - if (cache.containsKey(directionPair)) - return cache.get(directionPair); - - List quads = getQuads(stack, state, face, random); - cache.put(directionPair, quads); - return quads; - } + List getQuadsCached(ItemStack stack, @Nullable BlockState state, @Nullable Direction face, Random random); } diff --git a/gradle.properties b/gradle.properties index 3b20e7cb4..4c79e8cad 100755 --- a/gradle.properties +++ b/gradle.properties @@ -4,12 +4,12 @@ minecraft_version=1.20.1 enabled_platforms=fabric,forge archives_base_name=paladin-furniture-mod -mod_version=1.2.1 +mod_version=1.3-beta.1 maven_group=com.unlikepaladin architectury_version=9.1.12 -fabric_loader_version=0.14.22 +fabric_loader_version=0.16.5 fabric_api_version=0.87.0+1.20.1 yarn_mappings=1.20.1+build.10