mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Implemented Reconstructor random tooltips
This commit is contained in:
parent
773d723ce0
commit
c15fbab60b
2 changed files with 40 additions and 28 deletions
|
@ -33,7 +33,7 @@ public final class ActuallyBlocks {
|
||||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ActuallyAdditions.MODID);
|
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ActuallyAdditions.MODID);
|
||||||
public static final DeferredRegister<TileEntityType<?>> TILES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, ActuallyAdditions.MODID);
|
public static final DeferredRegister<TileEntityType<?>> TILES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, ActuallyAdditions.MODID);
|
||||||
|
|
||||||
private static final Item.Properties defaultBlockItemProperties = new Item.Properties().tab(ActuallyAdditions.GROUP).stacksTo(64);
|
public static final Item.Properties defaultBlockItemProperties = new Item.Properties().tab(ActuallyAdditions.GROUP).stacksTo(64);
|
||||||
|
|
||||||
public static final AbstractBlock.Properties miscBlockProperties = AbstractBlock.Properties.of(Material.STONE).harvestLevel(1).harvestTool(ToolType.PICKAXE).strength(1.5f, 10f);
|
public static final AbstractBlock.Properties miscBlockProperties = AbstractBlock.Properties.of(Material.STONE).harvestLevel(1).harvestTool(ToolType.PICKAXE).strength(1.5f, 10f);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public final class ActuallyBlocks {
|
||||||
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityVerticalDigger::new);
|
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityVerticalDigger::new);
|
||||||
|
|
||||||
public static final AABlockReg<BlockAtomicReconstructor, AABlockItem, TileEntityAtomicReconstructor> ATOMIC_RECONSTRUCTOR = new AABlockReg<>("atomic_reconstructor", BlockAtomicReconstructor::new,
|
public static final AABlockReg<BlockAtomicReconstructor, AABlockItem, TileEntityAtomicReconstructor> ATOMIC_RECONSTRUCTOR = new AABlockReg<>("atomic_reconstructor", BlockAtomicReconstructor::new,
|
||||||
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityAtomicReconstructor::new);
|
BlockAtomicReconstructor.TheItemBlock::new, TileEntityAtomicReconstructor::new);
|
||||||
public static final AABlockReg<BlockRangedCollector, AABlockItem, TileEntityRangedCollector> RANGED_COLLECTOR = new AABlockReg<>("ranged_collector", BlockRangedCollector::new,
|
public static final AABlockReg<BlockRangedCollector, AABlockItem, TileEntityRangedCollector> RANGED_COLLECTOR = new AABlockReg<>("ranged_collector", BlockRangedCollector::new,
|
||||||
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityRangedCollector::new);
|
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityRangedCollector::new);
|
||||||
public static final AABlockReg<BlockLongRangeBreaker, AABlockItem, TileEntityLongRangeBreaker> LONG_RANGE_BREAKER = new AABlockReg<>("long_range_breaker", BlockLongRangeBreaker::new,
|
public static final AABlockReg<BlockLongRangeBreaker, AABlockItem, TileEntityLongRangeBreaker> LONG_RANGE_BREAKER = new AABlockReg<>("long_range_breaker", BlockLongRangeBreaker::new,
|
||||||
|
|
|
@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||||
|
@ -19,9 +20,11 @@ import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Lang;
|
import de.ellpeck.actuallyadditions.mod.util.Lang;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.MainWindow;
|
import net.minecraft.client.MainWindow;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -43,7 +46,10 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container implements IHudDisplay {
|
public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container implements IHudDisplay {
|
||||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||||
|
@ -122,32 +128,38 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static class TheItemBlock extends ItemBlockBase {
|
public static class TheItemBlock extends AABlockItem {
|
||||||
//
|
|
||||||
// private long lastSysTime;
|
private long lastSysTime;
|
||||||
// private int toPick1;
|
private int toPick1;
|
||||||
// private int toPick2;
|
private int toPick2;
|
||||||
//
|
private final Block block;
|
||||||
// public TheItemBlock(Block block) {
|
|
||||||
// super(block, new Item.Properties().group(ActuallyAdditions.GROUP).setNoRepair());
|
public TheItemBlock(Block blockIn) {
|
||||||
// }
|
super(blockIn, ActuallyBlocks.defaultBlockItemProperties);
|
||||||
//
|
block = blockIn;
|
||||||
// @Override
|
}
|
||||||
// public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
|
|
||||||
// long sysTime = System.currentTimeMillis();
|
@OnlyIn(Dist.CLIENT)
|
||||||
//
|
@Override
|
||||||
// if (this.lastSysTime + 3000 < sysTime) {
|
public void appendHoverText(@Nonnull ItemStack pStack, @Nullable World pLevel, @Nonnull List<ITextComponent> pTooltip, @Nonnull ITooltipFlag pFlag) {
|
||||||
// this.lastSysTime = sysTime;
|
super.appendHoverText(pStack, pLevel, pTooltip, pFlag);
|
||||||
// if (Minecraft.getInstance().world != null) {
|
|
||||||
// this.toPick1 = Minecraft.getInstance().world.rand.nextInt(NAME_FLAVOR_AMOUNTS_1) + 1;
|
long sysTime = System.currentTimeMillis();
|
||||||
// this.toPick2 = Minecraft.getInstance().world.rand.nextInt(NAME_FLAVOR_AMOUNTS_2) + 1;
|
|
||||||
// }
|
if (this.lastSysTime + 3000 < sysTime) {
|
||||||
// }
|
this.lastSysTime = sysTime;
|
||||||
//
|
if (Minecraft.getInstance().level != null) {
|
||||||
// String base = "tile." + ActuallyAdditions.MODID + "." + ((BlockAtomicReconstructor) this.block).getBaseName() + ".info.";
|
Random random = Minecraft.getInstance().level.random;
|
||||||
// tooltip.add(StringUtil.localize(base + "1." + this.toPick1) + " " + StringUtil.localize(base + "2." + this.toPick2));
|
this.toPick1 = random.nextInt(NAME_FLAVOR_AMOUNTS_1) + 1;
|
||||||
// }
|
this.toPick2 = random.nextInt(NAME_FLAVOR_AMOUNTS_2) + 1;
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String base = block.getDescriptionId() + ".info.";
|
||||||
|
pTooltip.add(new TranslationTextComponent(base + "1." + this.toPick1).append(" ").append(new TranslationTextComponent(base + "2." + this.toPick2)).withStyle(s -> s.withColor(TextFormatting.GRAY)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasAnalogOutputSignal(BlockState state) {
|
public boolean hasAnalogOutputSignal(BlockState state) {
|
||||||
|
|
Loading…
Reference in a new issue