Fixes
Fix texture missing, adding translate.
This commit is contained in:
parent
64b4a2a2df
commit
98e57ff4a5
@ -1,5 +1,6 @@
|
|||||||
package com.learning.block;
|
package com.learning.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.block.AbstractBlock;
|
import net.minecraft.block.AbstractBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
@ -8,14 +9,23 @@ import net.minecraft.server.world.ServerWorld;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Item.TooltipContext;
|
||||||
|
import net.minecraft.item.tooltip.TooltipType;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
public class DamageBlock extends Block {
|
public class DamageBlock extends Block {
|
||||||
public DamageBlock(AbstractBlock.Settings settings) {
|
public DamageBlock(AbstractBlock.Settings settings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
}
|
}
|
||||||
public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity) {
|
public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity) {
|
||||||
if (!world.isClient()) {
|
if (!world.isClient() && entity.canHit()) {
|
||||||
entity.damage((ServerWorld)world, world.getDamageSources().generic(), 6f);
|
entity.damage((ServerWorld)world, world.getDamageSources().generic(), 6f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
|
||||||
|
super.appendTooltip(stack, context, tooltip, type);
|
||||||
|
tooltip.add(Text.translatable("toolTip.learning.damage_block"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,15 @@ public class CustomItem {
|
|||||||
|
|
||||||
public static Item toast = register("toast", Toast::new, new Item.Settings().food(Foods.toastFood));
|
public static Item toast = register("toast", Toast::new, new Item.Settings().food(Foods.toastFood));
|
||||||
public static Item bakedToast = register("baked_toast", BakedToast::new, new Item.Settings().food(Foods.bakedToastFood, ConsumableComponents.food().consumeSeconds(0.8f).build()));
|
public static Item bakedToast = register("baked_toast", BakedToast::new, new Item.Settings().food(Foods.bakedToastFood, ConsumableComponents.food().consumeSeconds(0.8f).build()));
|
||||||
public static Item damageBlock = register(CustomBlocks.damageBlock);
|
public static Item damageBlock = register(CustomBlocks.damageBlock, false);
|
||||||
|
|
||||||
private static Item register(Block block) {
|
private static Item register(Block block, Boolean useItemTranslateKey) {
|
||||||
RegistryKey<Item> key = keyOf(Registries.BLOCK.getKey(block).get());
|
RegistryKey<Item> key = keyOf(Registries.BLOCK.getKey(block).get());
|
||||||
return Registry.register(Registries.ITEM, key, new BlockItem(block, new Item.Settings().useItemPrefixedTranslationKey().registryKey(key)));
|
Item.Settings settings = new Item.Settings().registryKey(key);
|
||||||
|
if (!useItemTranslateKey) {
|
||||||
|
settings.useBlockPrefixedTranslationKey();
|
||||||
|
}
|
||||||
|
return register(key, (Item)new BlockItem(block, settings));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
{
|
{
|
||||||
"item.learning.toast": "Toast",
|
"item.learning.toast": "Toast",
|
||||||
|
"item.learning.baked_toast": "Baked Toast",
|
||||||
|
|
||||||
|
"block.learning.damage_block": "Damage Block",
|
||||||
|
|
||||||
"itemGroup.learning.custom_itemgroup": "My Dear...",
|
"itemGroup.learning.custom_itemgroup": "My Dear...",
|
||||||
|
|
||||||
"toolTip.learning.toast0": "A simple fastfood.",
|
"toolTip.learning.toast0": "A simple fastfood.",
|
||||||
"toolTip.learning.toast1": "Will be tastier after baking in the furnace!",
|
"toolTip.learning.toast1": "Will be tastier after baking in the furnace!",
|
||||||
|
"toolTip.learning.baked_toast": "Yummy!",
|
||||||
|
"toolTip.learning.damage_block": "Will hurt entities which stands on this block.",
|
||||||
|
|
||||||
"toolTip.learning.hold_control": "Hold §6Control §rto show more information.",
|
"toolTip.learning.hold_control": "Hold §6Control §rto show more information.",
|
||||||
"toolTip.learning.hold_shift": "Hold §6Shift §rto show more information."
|
"toolTip.learning.hold_shift": "Hold §6Shift §rto show more information."
|
||||||
}
|
}
|
||||||
|
10
src/main/resources/data/learning/recipe/baked_toast.json
Normal file
10
src/main/resources/data/learning/recipe/baked_toast.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:smelting",
|
||||||
|
"category": "food",
|
||||||
|
"cookingtime": 200,
|
||||||
|
"experience": 0.35,
|
||||||
|
"ingredient": "learning:toast",
|
||||||
|
"result": {
|
||||||
|
"id": "learning:baked_toast"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user