Skip to content

Commit

Permalink
Merge branch 'refs/heads/architectury-1.18.2' into architectury-1.19.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	forge/src/main/java/com/unlikepaladin/pfm/client/forge/ColorRegistryForge.java
  • Loading branch information
UnlikePaladin committed Oct 13, 2024
2 parents 22391ea + b5ec66c commit a070965
Show file tree
Hide file tree
Showing 208 changed files with 5,930 additions and 5,625 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.unlikepaladin.pfm.blocks;

import com.unlikepaladin.pfm.blocks.blockentities.ShowerHeadBlockEntity;
import com.unlikepaladin.pfm.items.LightSwitchItem;
import com.unlikepaladin.pfm.items.ShowerHandleItem;
import com.unlikepaladin.pfm.registry.BlockEntities;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
Expand Down Expand Up @@ -70,6 +73,22 @@ public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos po
};
}

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (player.getStackInHand(hand).getItem() instanceof ShowerHandleItem)
return super.onUse(state, world, pos, player, hand, hit);

if (world.isClient) {
return ActionResult.SUCCESS;
}
if (world.getBlockEntity(pos) instanceof ShowerHeadBlockEntity) {
ShowerHeadBlockEntity showerHeadBlockEntity = (ShowerHeadBlockEntity) world.getBlockEntity(pos);
showerHeadBlockEntity.setOpen(!showerHeadBlockEntity.isOpen());
world.updateListeners(pos, state, state, Block.NOTIFY_LISTENERS);
}
return super.onUse(state, world, pos, player, hand, hit);
}

@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return checkType(type, BlockEntities.SHOWER_HEAD_BLOCK_ENTITY, ShowerHeadBlockEntity::tick);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ public void readNbt(NbtCompound nbt) {
super.readNbt(nbt);
}

public boolean isOpen() {
return isOpen;
}

public void setOpen(boolean isOpen) {
if (isOpen){
}
this.isOpen = isOpen;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import com.unlikepaladin.pfm.blocks.*;
import com.unlikepaladin.pfm.blocks.blockentities.LampBlockEntity;
import com.unlikepaladin.pfm.data.FurnitureBlock;
import com.unlikepaladin.pfm.data.materials.VariantBase;
import com.unlikepaladin.pfm.data.materials.WoodVariant;
import com.unlikepaladin.pfm.data.materials.WoodVariantRegistry;
import com.unlikepaladin.pfm.registry.PaladinFurnitureModBlocksItems;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.color.item.ItemColorProvider;
Expand All @@ -15,6 +19,7 @@
import net.minecraft.client.render.RenderLayers;
import net.minecraft.item.Item;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -28,19 +33,17 @@ public static void registerBlockColors(){
sinks.forEach(block -> registerBlockColor(block, addWaterColor()));
registerBlockColor(PaladinFurnitureModBlocksItems.BASIC_TOILET, addToiletColor());
registerBlockColor(PaladinFurnitureModBlocksItems.BASIC_BATHTUB, addWaterColor());
registerItemColor(PaladinFurnitureModBlocksItems.BASIC_LAMP_ITEM, (stack, tintIndex) -> {
if (stack.hasNbt()) {
return DyeColor.byName(stack.getSubNbt("BlockEntityTag").getString("color"), DyeColor.WHITE).getMapColor().color;
}
return 0xFFFFFF;
});
registerBlockColor(PaladinFurnitureModBlocksItems.BASIC_LAMP, (state, world, pos, tintIndex) -> {
BlockEntity entity = world.getBlockEntity(pos);
if (entity != null) {
if (entity != null && tintIndex == 1) {
if (entity instanceof LampBlockEntity) {
DyeColor color = ((LampBlockEntity)entity).getPFMColor();
return color.getFireworkColor();
}
} else if (entity != null && tintIndex == 0) {
if (getBlockColor(((LampBlockEntity)entity).getVariant().getLogBlock()) != null) {
return getBlockColor(((LampBlockEntity)entity).getVariant().getLogBlock()).getColor(state, world, pos, tintIndex);
}
}
return 0xFFFFFF;
});
Expand All @@ -49,6 +52,20 @@ public static void registerBlockColors(){
pfmModCompatibility.getClientModCompatiblity().get().registerBlockColors();
}
});
PaladinFurnitureMod.furnitureEntryMap.forEach((key, value) -> {
value.getVariantToBlockMap().forEach((variantBase, block) -> {
BlockColorProvider blockColorProvider = getBlockColor(variantBase.getBaseBlock());
if (blockColorProvider != null) {
registerBlockColor(block, blockColorProvider);
}
});
value.getVariantToBlockMapNonBase().forEach((variantBase, block) -> {
BlockColorProvider blockColorProvider = getBlockColor(variantBase.getSecondaryBlock());
if (blockColorProvider != null) {
registerBlockColor(block, blockColorProvider);
}
});
});
}

public static void registerBlockRenderLayers() {
Expand All @@ -62,6 +79,32 @@ public static void registerBlockRenderLayers() {

public static void registerItemColors() {
registerItemColor(PaladinFurnitureModBlocksItems.BASIC_BATHTUB.asItem(), (stack, index) -> index == 1 ? 0x3c44a9 : 0xFFFFFF);
registerItemColor(PaladinFurnitureModBlocksItems.BASIC_LAMP_ITEM, (stack, tintIndex) -> {
if (stack.hasNbt() && tintIndex == 1) {
return DyeColor.byName(stack.getSubNbt("BlockEntityTag").getString("color"), DyeColor.WHITE).getMapColor().color;
} else if (stack.hasNbt() && tintIndex == 0) {
WoodVariant variantBase = WoodVariantRegistry.getVariant(Identifier.tryParse(stack.getSubNbt("BlockEntityTag").getString("variant")));
if (getItemColor(variantBase.getLogBlock().asItem()) != null) {
return getItemColor(variantBase.getLogBlock().asItem()).getColor(stack, tintIndex);
}
}
return 0xFFFFFF;
});

PaladinFurnitureMod.furnitureEntryMap.forEach((key, value) -> {
value.getVariantToBlockMap().forEach((variantBase, block) -> {
ItemColorProvider itemColorProvider = getItemColor(variantBase.getBaseBlock().asItem());
if (itemColorProvider != null) {
registerItemColor(block.asItem(), itemColorProvider);
}
});
value.getVariantToBlockMapNonBase().forEach((variantBase, block) -> {
ItemColorProvider itemColorProvider = getItemColor(variantBase.getBaseBlock().asItem());
if (itemColorProvider != null) {
registerItemColor(block.asItem(), itemColorProvider);
}
});
});
}

@ExpectPlatform
Expand All @@ -72,6 +115,15 @@ public static void registerItemColor(Item item, ItemColorProvider colorProvider)
public static void registerBlockColor(Block block, BlockColorProvider blockColorProvider){
throw new RuntimeException();
}
@ExpectPlatform
public static BlockColorProvider getBlockColor(Block block){
throw new RuntimeException();
}

@ExpectPlatform
public static ItemColorProvider getItemColor(Item item){
throw new RuntimeException();
}

@ExpectPlatform
public static void registerBlockToRenderLayer(Block block, RenderLayer renderLayer){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,8 @@ else if (block == PaladinFurnitureModBlocksItems.WHITE_MODERN_PENDANT)
}

if (!generatedRecipes.contains(getId(PaladinFurnitureModBlocksItems.BASIC_SHOWER_HEAD))) {
offerShowerHeadRecipe(PaladinFurnitureModBlocksItems.BASIC_SHOWER_HEAD, Ingredient.ofItems(Blocks.LIGHT_GRAY_CONCRETE), exporter);
offerShowerHandleRecipe(PaladinFurnitureModBlocksItems.BASIC_SHOWER_HANDLE_ITEM, Ingredient.ofItems(Blocks.LIGHT_GRAY_CONCRETE), exporter);
offerShowerHeadRecipe(PaladinFurnitureModBlocksItems.BASIC_SHOWER_HEAD, Ingredient.ofItems(Items.WATER_BUCKET), exporter);
offerShowerHandleRecipe(PaladinFurnitureModBlocksItems.BASIC_SHOWER_HANDLE_ITEM, Ingredient.ofItems(Blocks.LEVER), exporter);
generatedRecipes.add(getId(PaladinFurnitureModBlocksItems.BASIC_SHOWER_HEAD));
generatedRecipes.add(Registry.ITEM.getId(PaladinFurnitureModBlocksItems.BASIC_SHOWER_HANDLE_ITEM));
}
Expand Down Expand Up @@ -867,11 +867,11 @@ public static void offerBathtubRecipe(ItemConvertible output, Ingredient base, C
}

public static void offerShowerHeadRecipe(ItemConvertible output, Ingredient base, Consumer<RecipeJsonProvider> exporter) {
FurnitureRecipeJsonFactory.create(output, 1).group("bathroom").criterion("has_" + getItemPath(base), conditionsFromIngredient(base)).input(base, 3).input(Items.WATER_BUCKET, 1).input(Items.IRON_INGOT, 1).offerTo(exporter, new Identifier("pfm", output.asItem().getTranslationKey().replace("block.pfm.", "")));
FurnitureRecipeJsonFactory.create(output, 1).group("bathroom").criterion("has_" + getItemPath(base), conditionsFromIngredient(base)).input(base, 1).input(Items.REDSTONE, 1).input(Items.IRON_INGOT, 1).offerTo(exporter, new Identifier("pfm", output.asItem().getTranslationKey().replace("block.pfm.", "")));
}

public static void offerShowerHandleRecipe(ItemConvertible output, Ingredient base, Consumer<RecipeJsonProvider> exporter) {
FurnitureRecipeJsonFactory.create(output, 1).group("bathroom").criterion("has_" + getItemPath(base), conditionsFromIngredient(base)).input(base, 4).input(Items.REDSTONE, 1).input(Items.IRON_INGOT, 1).offerTo(exporter, new Identifier("pfm", output.asItem().getTranslationKey().replace("block.pfm.", "")));
FurnitureRecipeJsonFactory.create(output, 1).group("bathroom").criterion("has_" + getItemPath(base), conditionsFromIngredient(base)).input(base, 2).input(Items.REDSTONE, 1).input(Items.IRON_INGOT, 1).offerTo(exporter, new Identifier("pfm", output.asItem().getTranslationKey().replace("block.pfm.", "")));
}

public static void offerShowerTowelRecipe(ItemConvertible output, Ingredient base, Consumer<RecipeJsonProvider> exporter) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"credit": "By UnlikePaladin",
"textures": {
"particle": "minecraft:block/stripped_oak_log",
"texture": "minecraft:block/stripped_oak_log"
"particle": "block/stripped_oak_log",
"texture": "block/stripped_oak_log"
},
"elements": [
{
"from": [3, 0, 3],
"to": [13, 1.5, 13],
"rotation": {"angle": 0, "axis": "y", "origin": [0, -16, 0]},
"faces": {
"north": {"uv": [0, 0, 10, 1.5], "texture": "#texture", "cullface": "up"},
"east": {"uv": [0, 0, 10, 1.5], "texture": "#texture", "cullface": "up"},
"south": {"uv": [0, 0, 10, 1.5], "texture": "#texture", "cullface": "up"},
"west": {"uv": [0, 0, 10, 1.5], "texture": "#texture", "cullface": "up"},
"up": {"uv": [0, 0, 10, 10], "texture": "#texture", "cullface": "up"},
"down": {"uv": [0, 0, 10, 10], "texture": "#texture", "cullface": "up"}
"north": {"uv": [0, 0, 10, 1.5], "texture": "#texture", "cullface": "up", "tintindex": 0},
"east": {"uv": [0, 0, 10, 1.5], "texture": "#texture", "cullface": "up", "tintindex": 0},
"south": {"uv": [0, 0, 10, 1.5], "texture": "#texture", "cullface": "up", "tintindex": 0},
"west": {"uv": [0, 0, 10, 1.5], "texture": "#texture", "cullface": "up", "tintindex": 0},
"up": {"uv": [0, 0, 10, 10], "texture": "#texture", "cullface": "up", "tintindex": 0},
"down": {"uv": [0, 0, 10, 10], "texture": "#texture", "cullface": "up", "tintindex": 0}
}
},
{
"from": [7, 1.5, 7],
"to": [9, 16, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [0, -16, 0]},
"faces": {
"north": {"uv": [0, 0, 2, 14.5], "texture": "#texture", "cullface": "up"},
"east": {"uv": [0, 0, 2, 14.5], "texture": "#texture", "cullface": "up"},
"south": {"uv": [0, 0, 2, 14.5], "texture": "#texture", "cullface": "up"},
"west": {"uv": [0, 0, 2, 14.5], "texture": "#texture", "cullface": "up"},
"up": {"uv": [0, 0, 2, 2], "texture": "#texture", "cullface": "up"}
"north": {"uv": [0, 0, 2, 14.5], "texture": "#texture", "cullface": "up", "tintindex": 0},
"east": {"uv": [0, 0, 2, 14.5], "texture": "#texture", "cullface": "up", "tintindex": 0},
"south": {"uv": [0, 0, 2, 14.5], "texture": "#texture", "cullface": "up", "tintindex": 0},
"west": {"uv": [0, 0, 2, 14.5], "texture": "#texture", "cullface": "up", "tintindex": 0},
"up": {"uv": [0, 0, 2, 2], "texture": "#texture", "cullface": "up", "tintindex": 0}
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"credit": "By UnlikePaladin",
"textures": {
"texture": "minecraft:block/stripped_oak_log"
"texture": "block/stripped_oak_log"
},
"elements": [
{
"from": [7, 0, 7],
"to": [9, 16, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [0, -16, 0]},
"faces": {
"north": {"uv": [0, 0, 2, 16], "texture": "#texture", "cullface": "up"},
"east": {"uv": [0, 0, 2, 16], "texture": "#texture", "cullface": "up"},
"south": {"uv": [0, 0, 2, 16], "texture": "#texture", "cullface": "up"},
"west": {"uv": [0, 0, 2, 16], "texture": "#texture", "cullface": "up"},
"up": {"uv": [0, 0, 2, 2], "texture": "#texture", "cullface": "up"}
"north": {"uv": [0, 0, 2, 16], "texture": "#texture", "cullface": "up", "tintindex": 0},
"east": {"uv": [0, 0, 2, 16], "texture": "#texture", "cullface": "up", "tintindex": 0},
"south": {"uv": [0, 0, 2, 16], "texture": "#texture", "cullface": "up", "tintindex": 0},
"west": {"uv": [0, 0, 2, 16], "texture": "#texture", "cullface": "up", "tintindex": 0},
"up": {"uv": [0, 0, 2, 2], "texture": "#texture", "cullface": "up", "tintindex": 0}
}
}
],
Expand Down
Loading

0 comments on commit a070965

Please sign in to comment.