Skip to content

Commit

Permalink
Fix crockery combo placed item lighting
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNijjar committed Oct 16, 2023
1 parent 0fd66e8 commit e044c92
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ subprojects {
})

compileOnly(group = "com.teamresourceful", name = "yabn", version = "1.0.3")
"include"("modApi"(group = "com.teamresourceful.resourcefullib", name = "resourcefullib-$modLoader-$minecraftVersion", version = resourcefulLibVersion))
"modApi"(group = "com.teamresourceful.resourcefullib", name = "resourcefullib-$modLoader-$minecraftVersion", version = resourcefulLibVersion)
}

java {
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ before updating.**
- Add more trim types.
- Add better tooltips to make it more clear what's hammerable, what can hold cushions, and what can hold sheets.
- Shelf variants are now controlled via hammer.
- Fancy beds should no longer break with block entity optimization mods. I haven't tested, but it'll probably work now.
- Fixed fancy bed incompatibility with better beds
- Optimized fancy beds. Fancy beds are no longer block entities which improves their performance substantially,
far beyond even vanilla beds.
- Add highlight support to furniture. This improves the visual outline box of the furniture.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.1 2023-10-16T10:04:47.066914 Languages: en_us
0719a9abcf6e64a36b4aaa590a2f77d52ee9fd81 assets/handcrafted/lang/en_us.json
// 1.20.1 2023-10-16T17:42:00.338105 Languages: en_us
a196d1b282263a6be17d08f0beb35c310c7e97b1 assets/handcrafted/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@
"tooltip.handcrafted.bed_pillow": "Right-click with a cushion to change the bed's pillow color.",
"tooltip.handcrafted.bed_sheet": "Right-click with a sheet to change the bedsheets.",
"tooltip.handcrafted.counter": "Right-click with wood or stone to change the counter surface.",
"tooltip.handcrafted.crockery_combo": "Right-click with any item to place it on the plate.",
"tooltip.handcrafted.cushion": "Right-click with a cushion to change the block's look.",
"tooltip.handcrafted.hammer": "Changes the look of blocks.",
"tooltip.handcrafted.hammer_use_look": "Right-click with a hammer to change the block's look.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
import earth.terrarium.handcrafted.common.blocks.crockery.CrockeryBlockEntity;
import earth.terrarium.handcrafted.common.blocks.crockery.CrockeryComboBlock;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.world.item.ItemDisplayContext;

public class CrockeryRenderer implements BlockEntityRenderer<CrockeryBlockEntity> {
Expand All @@ -21,7 +19,7 @@ public void render(CrockeryBlockEntity entity, float partialTick, PoseStack pose
poseStack.translate(0.5, 1.25f / 16, 0.5);
poseStack.mulPose(Axis.YN.rotationDegrees(entity.getBlockState().getValue(CrockeryComboBlock.FACING).getOpposite().toYRot()));
poseStack.mulPose(Axis.XP.rotationDegrees(270));
Minecraft.getInstance().getItemRenderer().renderStatic(entity.getStack(), ItemDisplayContext.GROUND, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, poseStack, bufferSource, Minecraft.getInstance().level, 0);
Minecraft.getInstance().getItemRenderer().renderStatic(entity.getStack(), ItemDisplayContext.GROUND, packedLight, packedOverlay, poseStack, bufferSource, Minecraft.getInstance().level, 0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ public enum ColorProperty implements StringRepresentable {
BLACK,
;

public String toString() {
return getSerializedName();
}

@Override
public @NotNull String getSerializedName() {
return name().toLowerCase();
}

@Override
public String toString() {
return getSerializedName();
}

public static ColorProperty fromCushion(Item cushion) {
return ColorProperty.valueOf(BuiltInRegistries.ITEM.getKey(cushion).getPath().replace("_cushion", "").toUpperCase(Locale.ROOT));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ public enum CounterProperty implements StringRepresentable {
WARPED_PLANKS,
;

public String toString() {
return getSerializedName();
}

@Override
public @NotNull String getSerializedName() {
return name().toLowerCase();
}

@Override
public String toString() {
return getSerializedName();
}

public static CounterProperty fromBlock(Item block) {
return CounterProperty.valueOf(BuiltInRegistries.ITEM.getKey(block).getPath().toUpperCase(Locale.ROOT));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ public enum DirectionalBlockProperty implements StringRepresentable {
RIGHT,
;

public String toString() {
return getSerializedName();
}

@Override
public @NotNull String getSerializedName() {
return name().toLowerCase();
}

@Override
public String toString() {
return getSerializedName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public enum ModularSeatProperty implements StringRepresentable {
OUTER_RIGHT,
;

@Override
public @NotNull String getSerializedName() {
return name().toLowerCase();
}

@Override
public String toString() {
return getSerializedName();
}
Expand All @@ -25,8 +31,4 @@ public String getLocation() {
default -> getSerializedName();
};
}

public @NotNull String getSerializedName() {
return name().toLowerCase();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ public enum OptionalColorProperty implements StringRepresentable {
BLACK,
;

public String toString() {
return getSerializedName();
}

@Override
public @NotNull String getSerializedName() {
return name().toLowerCase();
}

@Override
public String toString() {
return getSerializedName();
}

public static OptionalColorProperty fromCushion(Item cushion) {
return OptionalColorProperty.valueOf(BuiltInRegistries.ITEM.getKey(cushion).getPath().replace("_cushion", "").toUpperCase(Locale.ROOT));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public enum TableProperty implements StringRepresentable {
WEST_SIDE,
;

public String toString() {
return getSerializedName();
}

@Override
public @NotNull String getSerializedName() {
return name().toLowerCase();
}

@Override
public String toString() {
return getSerializedName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ public enum TrimProperty implements StringRepresentable {
THIN,
;

public String toString() {
return getSerializedName();
}

@Override
public @NotNull String getSerializedName() {
return name().toLowerCase();
}

@Override
public String toString() {
return getSerializedName();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package earth.terrarium.handcrafted.common.blocks.crockery;

import earth.terrarium.handcrafted.common.blocks.base.SimpleBlock;
import earth.terrarium.handcrafted.common.constants.ConstantComponents;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
Expand All @@ -19,6 +22,9 @@
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

@SuppressWarnings("deprecation")
public class CrockeryComboBlock extends SimpleBlock implements EntityBlock {
Expand Down Expand Up @@ -50,6 +56,11 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return RenderShape.MODEL;
}

@Override
public void appendHoverText(ItemStack stack, @Nullable BlockGetter level, List<Component> tooltip, TooltipFlag flag) {
tooltip.add(ConstantComponents.CROCKERY_COMBO);
}

@Override
public @NotNull InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (level.getBlockEntity(pos) instanceof CrockeryBlockEntity crockery) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class ConstantComponents {
public static final Component HAMMER_USE_LOOK_SHIFT = Component.translatable("tooltip.handcrafted.hammer_use_look_shift").copy().withStyle(ChatFormatting.GRAY);

public static final Component COUNTER = Component.translatable("tooltip.handcrafted.counter").copy().withStyle(ChatFormatting.GRAY);
public static final Component CROCKERY_COMBO = Component.translatable("tooltip.handcrafted.crockery_combo").copy().withStyle(ChatFormatting.GRAY);

public static final Component PLACE_ON_FURNITURE = Component.translatable("tooltip.handcrafted.place_on_furniture").copy().withStyle(ChatFormatting.GRAY);
public static final Component CUSHION = Component.translatable("tooltip.handcrafted.cushion").copy().withStyle(ChatFormatting.GRAY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ protected void addTranslations() {
add(ConstantComponents.HAMMER_USE_LOOK.getString(), "Right-click with a hammer to change the block's look.");
add(ConstantComponents.HAMMER_USE_SHAPE.getString(), "Right-click with a hammer to change the block's shape.");
add(ConstantComponents.HAMMER_USE_LOOK_SHIFT.getString(), "Shift-right-click with a hammer to change the block's look.");

add(ConstantComponents.COUNTER.getString(), "Right-click with wood or stone to change the counter surface.");
add(ConstantComponents.CROCKERY_COMBO.getString(), "Right-click with any item to place it on the plate.");

add(ConstantComponents.PLACE_ON_FURNITURE.getString(), "Can be placed on furniture.");
add(ConstantComponents.CUSHION.getString(), "Right-click with a cushion to change the block's look.");
Expand Down

0 comments on commit e044c92

Please sign in to comment.