Skip to content

Commit

Permalink
Added #36
Browse files Browse the repository at this point in the history
  • Loading branch information
Chailotl committed Aug 30, 2024
1 parent fffe219 commit 57eaec4
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/main/java/dev/hephaestus/glowcase/block/HyperlinkBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
import net.minecraft.component.type.NbtComponent;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemActionResult;
import net.minecraft.util.hit.BlockHitResult;
Expand All @@ -22,6 +26,8 @@
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class HyperlinkBlock extends GlowcaseBlock implements BlockEntityProvider {
private static final VoxelShape OUTLINE = VoxelShapes.cuboid(0.25, 0.25, 0.25, 0.75, 0.75, 0.75);

Expand Down Expand Up @@ -69,4 +75,10 @@ protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, Worl
}
return ItemActionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
}

@Override
public void appendTooltip(ItemStack itemStack, Item.TooltipContext context, List<Text> tooltip, TooltipType options) {
tooltip.add(Text.translatable("block.glowcase.hyperlink_block.tooltip.0").formatted(Formatting.GRAY));
tooltip.add(Text.translatable("block.glowcase.generic.tooltip").formatted(Formatting.DARK_GRAY));
}
}
13 changes: 13 additions & 0 deletions src/main/java/dev/hephaestus/glowcase/block/ItemDisplayBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.Properties;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemActionResult;
import net.minecraft.util.hit.BlockHitResult;
Expand All @@ -26,6 +30,8 @@
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class ItemDisplayBlock extends GlowcaseBlock implements BlockEntityProvider {
private static final VoxelShape OUTLINE = VoxelShapes.cuboid(0.25, 0.25, 0.25, 0.75, 0.75, 0.75);

Expand Down Expand Up @@ -96,4 +102,11 @@ public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return checkType(type, Glowcase.ITEM_DISPLAY_BLOCK_ENTITY.get(), ItemDisplayBlockEntity::tick);
}

@Override
public void appendTooltip(ItemStack itemStack, Item.TooltipContext context, List<Text> tooltip, TooltipType options) {
tooltip.add(Text.translatable("block.glowcase.item_display_block.tooltip.0").formatted(Formatting.GRAY));
tooltip.add(Text.translatable("block.glowcase.item_display_block.tooltip.1").formatted(Formatting.DARK_GRAY));
tooltip.add(Text.translatable("block.glowcase.item_display_block.tooltip.2").formatted(Formatting.DARK_GRAY));
}
}
13 changes: 13 additions & 0 deletions src/main/java/dev/hephaestus/glowcase/block/TextBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
import net.minecraft.component.type.NbtComponent;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.Properties;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemActionResult;
import net.minecraft.util.hit.BlockHitResult;
Expand All @@ -22,6 +26,8 @@
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class TextBlock extends GlowcaseBlock implements BlockEntityProvider {
public TextBlock() {
super();
Expand Down Expand Up @@ -68,4 +74,11 @@ protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, Worl

return ItemActionResult.SUCCESS;
}

@Override
public void appendTooltip(ItemStack itemStack, Item.TooltipContext context, List<Text> tooltip, TooltipType options) {
tooltip.add(Text.translatable("block.glowcase.text_block.tooltip.0").formatted(Formatting.GRAY));
tooltip.add(Text.translatable("block.glowcase.generic.tooltip").formatted(Formatting.DARK_GRAY));
tooltip.add(Text.translatable("block.glowcase.text_block.tooltip.1").formatted(Formatting.DARK_GRAY));
}
}
9 changes: 8 additions & 1 deletion src/main/resources/assets/glowcase/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@
"item.glowcase.text_block": "Text Block",
"item.glowcase.hyperlink_block": "Hyperlink Block",
"gui.glowcase.title": "Title",
"gui.glowcase.url": "URL"
"gui.glowcase.url": "URL",
"block.glowcase.generic.tooltip": "Interact with a glowcase item to edit",
"block.glowcase.text_block.tooltip.0": "Displays formatted text",
"block.glowcase.text_block.tooltip.1": "Supports Placeholder QuickText",
"block.glowcase.hyperlink_block.tooltip.0": "Opens a URL when interacted",
"block.glowcase.item_display_block.tooltip.0": "Gives an item stack when interacted",
"block.glowcase.item_display_block.tooltip.1": "Interact with an item stack to set it",
"block.glowcase.item_display_block.tooltip.2": "Interact with the same item to edit"
}

0 comments on commit 57eaec4

Please sign in to comment.