Skip to content

Commit

Permalink
Merge branch 'refs/heads/architectury-1.20.4' into architectury-1.20.6
Browse files Browse the repository at this point in the history
# Conflicts:
#	common/src/main/java/com/unlikepaladin/pfm/client/ColorRegistry.java
#	common/src/main/java/com/unlikepaladin/pfm/runtime/data/PFMRecipeProvider.java
#	neoforge/src/main/resources/pfm.mixins.json
  • Loading branch information
UnlikePaladin committed Oct 14, 2024
2 parents 04bffe2 + 29655dc commit 155b79b
Show file tree
Hide file tree
Showing 216 changed files with 6,046 additions and 5,635 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@

import com.mojang.serialization.MapCodec;
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.BlockWithEntity;
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.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemActionResult;
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 @@ -78,6 +87,28 @@ public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos po
};
}

@Override
protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (stack.getItem() instanceof ShowerHandleItem)
return ItemActionResult.SKIP_DEFAULT_BLOCK_INTERACTION;

return ItemActionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}


@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult 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, hit);
}

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

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 @@ -5,9 +5,13 @@
import com.unlikepaladin.pfm.blocks.blockentities.LampBlockEntity;
import com.unlikepaladin.pfm.data.FurnitureBlock;
import com.unlikepaladin.pfm.items.PFMComponents;
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 @@ -17,6 +21,7 @@
import net.minecraft.component.DataComponentTypes;
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 @@ -30,19 +35,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.contains(PFMComponents.COLOR_COMPONENT)) {
return stack.getOrDefault(PFMComponents.COLOR_COMPONENT, 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.getMapColor().color;
}
} 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 @@ -51,6 +54,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 @@ -64,6 +81,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.contains(PFMComponents.COLOR_COMPONENT) && tintIndex == 1) {
return stack.getOrDefault(PFMComponents.COLOR_COMPONENT, DyeColor.WHITE).getMapColor().color;
} else if (stack.contains(PFMComponents.VARIANT_COMPONENT) && tintIndex == 0) {
WoodVariant variantBase = WoodVariantRegistry.getVariant(stack.getOrDefault(PFMComponents.VARIANT_COMPONENT, WoodVariantRegistry.OAK.identifier));
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 @@ -74,6 +117,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 @@ -19,11 +19,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 @@ -149,24 +151,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 @@ -219,23 +221,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 @@ -596,8 +596,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.getDefaultStack(), Ingredient.ofItems(Blocks.LIGHT_GRAY_CONCRETE), exporter);
offerShowerHeadRecipe(PaladinFurnitureModBlocksItems.BASIC_SHOWER_HEAD, Ingredient.ofItems(Items.WATER_BUCKET), exporter);
offerShowerHandleRecipe(PaladinFurnitureModBlocksItems.BASIC_SHOWER_HANDLE_ITEM.getDefaultStack(), 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 @@ -901,11 +901,11 @@ public static void offerBathtubRecipe(ItemConvertible output, Ingredient base, R
}

public static void offerShowerHeadRecipe(ItemConvertible output, Ingredient base, RecipeExporter 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(ItemStack output, Ingredient base, RecipeExporter exporter) {
FurnitureRecipeJsonFactory.create(output).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.getItem().getTranslationKey().replace("block.pfm.", "")));
FurnitureRecipeJsonFactory.create(output).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.getItem().getTranslationKey().replace("block.pfm.", "")));
}

public static void offerShowerTowelRecipe(ItemConvertible output, Ingredient base, RecipeExporter 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
Loading

0 comments on commit 155b79b

Please sign in to comment.