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
  • Loading branch information
UnlikePaladin committed Oct 13, 2024
2 parents 3a1a883 + 5d76f3d commit 13e6faf
Show file tree
Hide file tree
Showing 209 changed files with 5,946 additions and 5,639 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 @@ -18,11 +18,13 @@
import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.screen.narration.NarrationPart;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.ElementListWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.*;
import net.minecraft.util.Formatting;

import java.util.*;
import java.util.function.Consumer;
Expand Down Expand Up @@ -147,24 +149,24 @@ public class BooleanEntry
private final ButtonWidget valueButton;
private final ButtonWidget resetButton;

private final Supplier<MutableText> supplier;
private final Tooltip supplier;
int index;
boolean hasChanges = false;
BooleanEntry(final BooleanConfigOption configOption, final Text optionName, int index) {
this.configOption = configOption;
this.optionName = optionName;
this.index = index;
this.supplier = () -> {
final MutableText sideText = configOption.getSide() == Side.CLIENT ? Text.translatable("pfm.option.client").setStyle(Style.EMPTY.withItalic(false).withBold(true).withColor(0xf77f34)) : Text.translatable("pfm.option.server").setStyle((Style.EMPTY.withItalic(false).withBold(true).withColor(0xf77f34)));
final MutableText styledTooltip = ((MutableText)configOption.getToolTip()).setStyle(Style.EMPTY.withItalic(true));
return sideText.append(Text.literal("\n")).append(styledTooltip);
};
final MutableText sideText = configOption.getSide() == Side.CLIENT ? Text.translatable("pfm.option.client").setStyle(Style.EMPTY.withItalic(false).withBold(true).withColor(0xf77f34)) : Text.translatable("pfm.option.server").setStyle((Style.EMPTY.withItalic(false).withBold(true).withColor(0xf77f34)));
final MutableText styledTooltip = ((MutableText)configOption.getToolTip()).setStyle(Style.EMPTY.withItalic(true).withBold(false).withColor(Formatting.WHITE));
final Text tooltipText = sideText.append(Text.literal("\n")).append(styledTooltip);
this.supplier = Tooltip.of(tooltipText);

this.valueButton = ButtonWidget.builder(optionName, button -> {
PFMOptionListWidget.this.parent.focusedConfigOption = configOption;
PFMOptionListWidget.this.newConfigValues.put(configOption, !PFMOptionListWidget.this.newConfigValues.get(configOption));
hasChanges = !hasChanges;
PFMOptionListWidget.this.hasChanges.set(index, hasChanges);
}).dimensions(0,0,75,20).narrationSupplier(textSupplier -> this.supplier.get()).build();
}).tooltip(supplier).dimensions(0,0,75,20).narrationSupplier(Supplier::get).build();

this.resetButton = ButtonWidget.builder(Text.translatable("controls.reset"), button -> {
PFMOptionListWidget.this.newConfigValues.put(configOption, configOption.getDefaultValue());
Expand Down Expand Up @@ -217,23 +219,23 @@ public class ButtonEntry
private final Text optionName;
private final ButtonWidget button;

private final Supplier<MutableText> supplier;
private final Tooltip supplier;
private final Side side;
ButtonEntry(Side side, final Text optionName, Text buttonText, Text tooltip, ButtonWidget.PressAction pressAction) {
this.optionName = optionName;
this.side = side;
this.supplier = () -> {
final MutableText sideText = side == Side.CLIENT ? Text.translatable("pfm.option.client").setStyle(Style.EMPTY.withItalic(false).withBold(true).withColor(0xf77f34)) : Text.translatable("pfm.option.server").setStyle((Style.EMPTY.withItalic(false).withBold(true).withColor(0xf77f34)));
final MutableText styledTooltip = ((MutableText)tooltip).setStyle(Style.EMPTY.withItalic(true));
return sideText.append(Text.literal("\n")).append(styledTooltip);
};
final MutableText sideText = side == Side.CLIENT ? Text.translatable("pfm.option.client").setStyle(Style.EMPTY.withItalic(false).withBold(true).withColor(0xf77f34)) : Text.translatable("pfm.option.server").setStyle((Style.EMPTY.withItalic(false).withBold(true).withColor(0xf77f34)));
final MutableText styledTooltip = ((MutableText)tooltip).setStyle(Style.EMPTY.withItalic(true).withBold(false).withColor(Formatting.WHITE));
final Text tooltipText = sideText.append(Text.literal("\n")).append(styledTooltip);
this.supplier = Tooltip.of(tooltipText);

this.button = new ButtonWidget(0, 0, 135, 20, buttonText, pressAction, textSupplier -> supplier.get()){
this.button = new ButtonWidget(0, 0, 135, 20, buttonText, pressAction, Supplier::get){
@Override
protected MutableText getNarrationMessage() {
return (MutableText) optionName;
}
};
button.setTooltip(supplier);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,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(Registries.ITEM.getId(PaladinFurnitureModBlocksItems.BASIC_SHOWER_HANDLE_ITEM));
}
Expand Down Expand Up @@ -887,11 +887,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 13e6faf

Please sign in to comment.