use of net.minecraft.util.text.TranslationTextComponent in project BluePower by Qmunity.
the class BlockBPMicroblock method getDrops.
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
TileEntity tileentity = builder.getParameter(LootParameters.BLOCK_ENTITY);
List<ItemStack> itemStacks = new ArrayList<>();
if (tileentity instanceof TileBPMultipart) {
tileentity = ((TileBPMultipart) tileentity).getTileForState(state);
}
if (tileentity instanceof TileBPMicroblock) {
CompoundNBT nbt = new CompoundNBT();
nbt.putString("block", ((TileBPMicroblock) tileentity).getBlock().getRegistryName().toString());
ItemStack stack = new ItemStack(this);
stack.setTag(nbt);
stack.setHoverName(new TranslationTextComponent(((TileBPMicroblock) tileentity).getBlock().getDescriptionId()).append(new StringTextComponent(" ")).append(new TranslationTextComponent(this.getDescriptionId())));
itemStacks.add(stack);
}
return itemStacks;
}
use of net.minecraft.util.text.TranslationTextComponent in project AgriCraft by AgriCraft.
the class GuiPlugin method onSeedAnalyzerRightClick.
public void onSeedAnalyzerRightClick(PlayerInteractEvent.RightClickBlock event) {
BlockPos pos = event.getPos();
BlockState state = event.getWorld().getBlockState(pos);
if (event.getPlayer().isSneaking()) {
return;
}
if (state.getBlock() != AgriCraft.instance.getModBlockRegistry().seed_analyzer.getBlock()) {
return;
}
event.setCancellationResult(ActionResultType.SUCCESS);
event.setCanceled(true);
if (event.getPlayer().world.isRemote) {
return;
}
INamedContainerProvider containerProvider = new INamedContainerProvider() {
@Nonnull
@Override
public ITextComponent getDisplayName() {
return new TranslationTextComponent("screen.agricraft.seed_analyzer");
}
@Override
public Container createMenu(int id, @Nonnull PlayerInventory playerInventory, @Nonnull PlayerEntity player) {
return new SeedAnalyzerContainer(id, event.getWorld(), playerInventory, pos);
}
};
NetworkHooks.openGui((ServerPlayerEntity) event.getPlayer(), containerProvider, pos);
}
use of net.minecraft.util.text.TranslationTextComponent in project Geolosys by oitsjustjose.
the class ProPickItem method prospectChunk.
private boolean prospectChunk(World world, ItemStack stack, BlockPos pos, PlayerEntity player) {
HashSet<BlockState> foundBlocks = new HashSet<BlockState>();
HashSet<BlockState> depositBlocks = Prospecting.getDepositBlocks();
ChunkPos tempPos = new ChunkPos(pos);
for (int x = tempPos.getXStart(); x <= tempPos.getXEnd(); x++) {
for (int z = tempPos.getZStart(); z <= tempPos.getZEnd(); z++) {
for (int y = 0; y < world.getHeight(); y++) {
BlockState state = world.getBlockState(new BlockPos(x, y, z));
if (depositBlocks.contains(state)) {
foundBlocks.add(state);
}
}
}
}
if (!foundBlocks.isEmpty()) {
Geolosys.proxy.sendProspectingMessage(player, foundBlocks, null);
return true;
}
player.sendStatusMessage(new TranslationTextComponent("geolosys.pro_pick.tooltip.nonefound_surface"), true);
return false;
}
Aggregations